home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / MacOS 8 Resources / Developer Tools / Mac OS 8 Interfaces & Libraries / Interfaces / CIncludes / OpenTransport.h < prev    next >
C/C++ Source or Header  |  1996-05-01  |  89KB  |  2,591 lines

  1. /*
  2.     File:        OpenTransport.h
  3.  
  4.     Contains:    Open Transport client interface file.  This contains all the client APIs
  5.                 that are available to 68K clients on PowerPC machines running System 7.
  6.  
  7.     Copyright:    © 1993-1996 by Apple Computer, Inc. and Mentat Inc., all rights reserved.
  8.  
  9.  
  10. */
  11.  
  12. #ifndef __OPENTRANSPORT__
  13. #define __OPENTRANSPORT__
  14.  
  15. #ifndef SystemSevenOrLater
  16. #define SystemSevenOrLater    1
  17. #endif
  18.  
  19. #ifndef __TYPES__
  20. #include <Types.h>
  21. #endif
  22. #ifndef __STDDEF__
  23. #include <stddef.h>
  24. #endif
  25. #ifndef __STRING__
  26. #include <string.h>
  27. #endif
  28.  
  29. #if GENERATING68K && defined(__MWERKS__)
  30. #pragma pointers_in_D0
  31. #endif
  32.  
  33. /*    -------------------------------------------------------------------------
  34.     Define what functions look like
  35.     ------------------------------------------------------------------------- */
  36.     
  37. #define _CDECL
  38. #define _MDECL
  39.  
  40. #if defined(__SC__) || defined(THINK_CPLUS) || defined(__MRC__)
  41.     #undef _CDECL
  42.     #undef _MDECL
  43.     #define _CDECL            _cdecl
  44.     #define _MDECL            _cdecl
  45. #endif
  46.  
  47. #if GENERATING68K
  48.     typedef unsigned int    uchar_p;
  49.     typedef unsigned int    ushort_p;
  50.     typedef int                short_p;
  51.     typedef int                char_p;
  52.     typedef int                boolean_p;
  53. #else
  54.     typedef unsigned char    uchar_p;
  55.     typedef unsigned short    ushort_p;
  56.     typedef short            short_p;
  57.     typedef char            char_p;
  58.     typedef Boolean            boolean_p;
  59. #endif
  60.  
  61. #ifndef __MIXEDMODE__
  62. #include <MixedMode.h>
  63. #endif
  64.  
  65. #ifndef OTKERNEL
  66. #define OTKERNEL    0
  67. #endif
  68.  
  69. #if GENERATINGPOWERPC
  70. #pragma options align=mac68k
  71. #endif
  72.  
  73. /*******************************************************************************
  74. ** Some prefixes for shared libraries
  75. ********************************************************************************/
  76.  
  77. #define kOTLibraryVersion        "1.0"
  78.  
  79. #define kOTLibraryPrefix         "OTLib$"
  80.  
  81. #define kOTModulePrefix            "OTModl$"
  82. #define kOTKernelPrefix            "OTKrnl$"
  83. #define kOTClientPrefix            "OTClnt$"
  84. #define kOTSupportPrefix        "OTSupp$"
  85.  
  86. /*******************************************************************************
  87. ** Gestalt values for Open Transport
  88. ********************************************************************************/
  89.  
  90. enum
  91. {
  92.     gestaltOpenTptVersions            = 'otvr',
  93.     gestaltOpenTpt                    = 'otan',
  94.     gestaltOpenTptPresent            = 0x00000001,
  95.     gestaltOpenTptLoaded            = 0x00000002,
  96.     gestaltOpenTptAppleTalkPresent    = 0x00000004,
  97.     gestaltOpenTptAppleTalkLoaded    = 0x00000008,
  98.     gestaltOpenTptTCPPresent        = 0x00000010,
  99.     gestaltOpenTptTCPLoaded            = 0x00000020,
  100.     gestaltOpenTptIPXSPXPresent        = 0x00000040,
  101.     gestaltOpenTptIPXSPXLoaded        = 0x00000080
  102. };
  103.  
  104. /*******************************************************************************
  105. ** Some typedefs used by the OpenTransport system
  106. ********************************************************************************/
  107.  
  108. /*    -------------------------------------------------------------------------
  109.     Miscellaneous typedefs
  110.     ------------------------------------------------------------------------- */
  111.  
  112.     typedef UInt32                OTTimeout;        /* A millisecond timeout value                    */
  113.     typedef long                OTSequence;        /* An ID number in connections/transactions        */
  114.     typedef long                OTNameID;        /* An ID number for registered names            */
  115.     typedef SInt32                OTReason;        /* A protocol-specific reason code for failure    */
  116.                                                 /* Usually a Unix-style positive error code        */
  117.     typedef UInt32                OTQLen;            /* # outstanding connection requests at 1 time    */
  118.     typedef void*                OTClient;        /* value describing a client                    */
  119.     typedef UInt8*                OTClientName;    /* Will become internationalizeable shortly        */
  120.     typedef void*                 (* _CDECL OTAllocMemProcPtr)(size_t);
  121.     typedef void                 (* _CDECL OTFreeMemProcPtr)(void*);
  122.     
  123. /*    -------------------------------------------------------------------------
  124.     OTOpenFlags - flags used for opening providers
  125.     ------------------------------------------------------------------------- */
  126.  
  127.     typedef UInt32                OTOpenFlags;
  128.  
  129.         enum
  130.         {
  131.             O_ASYNC        = 0x01,
  132.             O_NDELAY    = 0x04,
  133.             O_NONBLOCK    = 0x04
  134.         };
  135.  
  136. /*    -------------------------------------------------------------------------
  137.     StdCLib-style Error codes
  138.     ------------------------------------------------------------------------- */
  139.  
  140.     typedef UInt16                    OTUnixErr;
  141.         /*
  142.          * There may be some error code confusions with other compiler vendor header
  143.          * files - However, these match both MPW and AIX definitions.
  144.          * We undefine the #defined ones we know about so that we can put them
  145.          * in an enum.
  146.          */
  147.          
  148.         #undef EPERM
  149.         #undef ENOENT
  150.         #undef ENORSRC
  151.         #undef EINTR
  152.         #undef EIO
  153.         #undef ENXIO
  154.         #undef E2BIG
  155.         #undef EBADF
  156.         #undef EAGAIN
  157.         #undef ENOMEM
  158.         #undef EACCES
  159.         #undef EFAULT
  160.         #undef EBUSY
  161.         #undef EEXIST
  162.         #undef ENODEV
  163.         #undef EINVAL
  164.         #undef ENOTTY
  165.         #undef ERANGE
  166.         #undef ESRCH
  167.         #undef EPIPE
  168.  
  169.         enum
  170.         {
  171.             EPERM            = 1,        /* Permission denied                    */
  172.             ENOENT            = 2,        /* No such file or directory            */
  173.             ENORSRC          = 3,        /* No such resource                        */
  174.             EINTR            = 4,        /* Interrupted system service            */
  175.             EIO             = 5,        /* I/O error                            */
  176.             ENXIO            = 6,        /* No such device or address            */
  177.             EBADF             = 9,        /* Bad file number                        */
  178.             EAGAIN            = 11,        /* Try operation again later            */
  179.             ENOMEM            = 12,        /* Not enough space                        */
  180.             EACCES            = 13,        /* Permission denied                    */
  181.             EFAULT            = 14,        /* Bad address                            */
  182.             EBUSY            = 16,        /* Device or resource busy                */
  183.             EEXIST            = 17,        /* File exists                            */
  184.             ENODEV            = 19,        /* No such device                        */
  185.             EINVAL            = 22,        /* Invalid argument                        */
  186.             ENOTTY            = 25,        /* Not a character device                */
  187.             EPIPE            = 32,        /* Broken pipe                            */
  188.             ERANGE            = 34,        /* Math result not representable        */
  189.             EDEADLK            = 35,        /* Call would block so was aborted        */ 
  190.             EWOULDBLOCK        = EDEADLK,    /* Or a deadlock would occur            */
  191.             EALREADY        = 37,
  192.             ENOTSOCK        = 38,        /* Socket operation on non-socket        */
  193.             EDESTADDRREQ    = 39,        /* Destination address required            */
  194.             EMSGSIZE        = 40,        /* Message too long                        */
  195.             EPROTOTYPE        = 41,        /* Protocol wrong type for socket        */
  196.             ENOPROTOOPT        = 42,        /* Protocol not available                */
  197.             EPROTONOSUPPORT    = 43,        /* Protocol not supported                */
  198.             ESOCKTNOSUPPORT    = 44,        /* Socket type not supported            */
  199.             EOPNOTSUPP        = 45,        /* Operation not supported on socket    */
  200.             EADDRINUSE        = 48,        /* Address already in use                */
  201.             EADDRNOTAVAIL    = 49,        /* Can't assign requested address        */
  202.         
  203.             ENETDOWN        = 50,        /* Network is down                        */
  204.             ENETUNREACH        = 51,        /* Network is unreachable                */
  205.             ENETRESET        = 52,        /* Network dropped connection on reset    */
  206.             ECONNABORTED    = 53,        /* Software caused connection abort        */
  207.             ECONNRESET        = 54,        /* Connection reset by peer                */
  208.             ENOBUFS            = 55,        /* No buffer space available            */
  209.             EISCONN            = 56,        /* Socket is already connected            */
  210.             ENOTCONN        = 57,        /* Socket is not connected                */
  211.             ESHUTDOWN        = 58,        /* Can't send after socket shutdown        */
  212.             ETOOMANYREFS    = 59,        /* Too many references: can't splice    */
  213.             ETIMEDOUT        = 60,        /* Connection timed out                    */
  214.             ECONNREFUSED    = 61,        /* Connection refused                    */
  215.         
  216.             EHOSTDOWN        = 64,        /* Host is down                            */
  217.             EHOSTUNREACH    = 65,        /* No route to host                        */
  218.         
  219.             EPROTO            = 70,
  220.             ETIME            = 71,
  221.             ENOSR            = 72,
  222.             EBADMSG            = 73,
  223.             ECANCEL            = 74,
  224.             ENOSTR            = 75,
  225.             ENODATA            = 76,
  226.             EINPROGRESS        = 77,
  227.         
  228.             ESRCH             = 78,
  229.             ENOMSG            = 79,
  230.         
  231.             ELASTERRNO        = 79
  232.         };
  233.  
  234. /*    -------------------------------------------------------------------------
  235.     Open Transport/XTI Error codes
  236.     ------------------------------------------------------------------------- */
  237.  
  238.     typedef UInt16                    OTXTIErr;
  239.  
  240.         enum
  241.         {
  242.             TSUCCESS        = 0,    /* No Error occurred                        */
  243.             TBADADDR        = 1,    /* A Bad address was specified                */
  244.             TBADOPT         = 2,    /* A Bad option was specified                */
  245.             TACCES            = 3,    /* Missing access permission                */
  246.             TBADF            = 4,    /* Bad provider reference                    */
  247.             TNOADDR         = 5,    /* No address was specified                    */
  248.             TOUTSTATE        = 6,    /* Call issued in wrong state                */
  249.             TBADSEQ         = 7,    /* Sequence specified does not exist        */
  250.             TSYSERR         = 8,    /* A system error occurred                    */
  251.             TLOOK            = 9,    /* An event occurred - call Look()            */
  252.             TBADDATA        = 10,    /* An illegal amount of data was specified    */
  253.             TBUFOVFLW        = 11,    /* Passed buffer not big enough                */
  254.             TFLOW            = 12,    /* Provider is flow-controlled                */
  255.             TNODATA         = 13,    /* No data available for reading            */
  256.             TNODIS            = 14,    /* No disconnect indication available        */
  257.             TNOUDERR        = 15,    /* No Unit Data Error indication available    */
  258.             TBADFLAG        = 16,    /* A Bad flag value was supplied            */
  259.             TNOREL            = 17,    /* No orderly release indication available    */
  260.             TNOTSUPPORT     = 18,    /* Command is not supported                    */
  261.             TSTATECHNG        = 19,    /* State is changing - try again later        */
  262.             TNOSTRUCTYPE    = 20,    /* Bad structure type requested for OTAlloc    */
  263.             TBADNAME        = 21,    /* A bad endpoint name was supplied            */
  264.             TBADQLEN        = 22,    /* A Bind to an in-use address with qlen > 0*/
  265.             TADDRBUSY        = 23,    /* Address requested is already in use        */
  266.             TINDOUT         = 24,    /* Accept failed because of pending listen    */
  267.             TPROVMISMATCH    = 25,    /* Tried to accept on incompatible endpoint    */
  268.             TRESQLEN        = 26,
  269.             TRESADDR        = 27,
  270.             TQFULL            = 28,
  271.             TPROTO            = 29,    /* An unspecified provider error occurred    */
  272.             TBADSYNC        = 30,    /* A synchronous call at interrupt time        */
  273.             TCANCELED        = 31,    /* The command was cancelled                */
  274.             
  275.             TLASTXTIERROR    = 31
  276.         };
  277.  
  278. /*    -------------------------------------------------------------------------
  279.     Standard negative error codes conforming to both the Open Transport/XTI
  280.     errors and the Exxxxx StdCLib errors.
  281.     These are returned as OSStatus' from functions, and to the OTResult parameter
  282.     of a notification function or method.  However, OTResult may sometimes
  283.     contain other values depending on the notification.
  284.     ------------------------------------------------------------------------- */
  285.  
  286.     typedef SInt32                OTResult;
  287.         /*
  288.          * These map the Open Transport/XTI errors (the Txxxx error codes), and the
  289.          * StdCLib Exxxx error codes into unique spaces in the Apple OSStatus space.
  290.          */
  291.         #define XTI2OSStatus(x)            (-3149 - (x))
  292.         #define E2OSStatus(x)            (-3199 - (x))
  293.  
  294.         #define OSStatus2XTI(x)            ((OTXTIErr)(-3149 - (x)))
  295.         #define OSStatus2E(x)            ((OTUnixErr)(-3199 - (x)))
  296.         
  297.         #define IsXTIError(x)            ((x) < -3149 && (x) >= (-3149 - TLASTXTIERROR))
  298.         #define IsEError(x)                ((x) < -3199 && (x) >= (-3199 - ELASTERRNO))
  299.  
  300.         enum
  301.         {
  302.             kOTNoError                = (OSStatus)0,                    /* No Error occurred                        */
  303.             kOTOutOfMemoryErr        = E2OSStatus(ENOMEM),
  304.             kOTNotFoundErr            = E2OSStatus(ENOENT),
  305.             kOTDuplicateFoundErr    = E2OSStatus(EEXIST),
  306.             /*
  307.              * Remapped XTI error codes
  308.              */
  309.             kOTBadAddressErr        = XTI2OSStatus(TBADADDR),        /* A Bad address was specified                */
  310.             kOTBadOptionErr            = XTI2OSStatus(TBADOPT),        /* A Bad option was specified                */
  311.             kOTAccessErr            = XTI2OSStatus(TACCES),            /* Missing access permission                */
  312.             kOTBadReferenceErr        = XTI2OSStatus(TBADF),            /* Bad provider reference                    */
  313.             kOTNoAddressErr            = XTI2OSStatus(TNOADDR),        /* No address was specified                    */
  314.             kOTOutStateErr            = XTI2OSStatus(TOUTSTATE),        /* Call issued in wrong state                */
  315.             kOTBadSequenceErr        = XTI2OSStatus(TBADSEQ),        /* Sequence specified does not exist        */
  316.             kOTSysErrorErr            = XTI2OSStatus(TSYSERR),        /* A system error occurred                    */
  317.             kOTLookErr                = XTI2OSStatus(TLOOK),            /* An event occurred - call Look()            */
  318.             kOTBadDataErr            = XTI2OSStatus(TBADDATA),        /* An illegal amount of data was specified    */
  319.             kOTBufferOverflowErr    = XTI2OSStatus(TBUFOVFLW),        /* Passed buffer not big enough                */
  320.             kOTFlowErr                = XTI2OSStatus(TFLOW),            /* Provider is flow-controlled                */
  321.             kOTNoDataErr            = XTI2OSStatus(TNODATA),        /* No data available for reading            */
  322.             kOTNoDisconnectErr        = XTI2OSStatus(TNODIS),            /* No disconnect indication available        */
  323.             kOTNoUDErrErr            = XTI2OSStatus(TNOUDERR),        /* No Unit Data Error indication available    */
  324.             kOTBadFlagErr            = XTI2OSStatus(TBADFLAG),        /* A Bad flag value was supplied            */
  325.             kOTNoReleaseErr            = XTI2OSStatus(TNOREL),            /* No orderly release indication available    */
  326.             kOTNotSupportedErr        = XTI2OSStatus(TNOTSUPPORT),    /* Command is not supported                    */
  327.             kOTStateChangeErr        = XTI2OSStatus(TSTATECHNG),        /* State is changing - try again later        */
  328.             kOTNoStructureTypeErr    = XTI2OSStatus(TNOSTRUCTYPE),    /* Bad structure type requested for OTAlloc    */
  329.             kOTBadNameErr            = XTI2OSStatus(TBADNAME),        /* A bad endpoint name was supplied            */
  330.             kOTBadQLenErr            = XTI2OSStatus(TBADQLEN),        /* A Bind to an in-use addr with qlen > 0    */
  331.             kOTAddressBusyErr        = XTI2OSStatus(TADDRBUSY),        /* Address requested is already in use        */
  332.             kOTIndOutErr            = XTI2OSStatus(TINDOUT),        /* Accept failed because of pending listen    */
  333.             kOTProviderMismatchErr    = XTI2OSStatus(TPROVMISMATCH),    /* Tried to accept on incompatible endpoint    */
  334.             kOTResQLenErr            = XTI2OSStatus(TRESQLEN),
  335.             kOTResAddressErr        = XTI2OSStatus(TRESADDR),
  336.             kOTQFullErr                = XTI2OSStatus(TQFULL),
  337.             kOTProtocolErr            = XTI2OSStatus(TPROTO),            /* An unspecified provider error occurred    */
  338.             kOTBadSyncErr            = XTI2OSStatus(TBADSYNC),        /* A synchronous call at interrupt time        */
  339.             kOTCanceledErr            = XTI2OSStatus(TCANCELED),        /* The command was cancelled                */
  340.             /*
  341.              * Remapped StdCLib error codes. %%% Remove ones we don't actually return.
  342.              */
  343.             kEPERMErr                = E2OSStatus(EPERM),            /* Permission denied                    */
  344.             kENOENTErr                = E2OSStatus(ENOENT),            /* No such file or directory            */
  345.             kENORSRCErr                = E2OSStatus(ENORSRC),            /* No such resource                        */
  346.             kEINTRErr                = E2OSStatus(EINTR),            /* Interrupted system service            */
  347.             kEIOErr                    = E2OSStatus(EIO),                /* I/O error                            */
  348.             kENXIOErr                = E2OSStatus(ENXIO),            /* No such device or address            */
  349.             kEBADFErr                = E2OSStatus(EBADF),            /* Bad file number                        */
  350.             kEAGAINErr                = E2OSStatus(EAGAIN),            /* Try operation again later            */
  351.             kENOMEMErr                = E2OSStatus(ENOMEM),            /* Not enough space                        */
  352.             kEACCESErr                = E2OSStatus(EACCES),            /* Permission denied                    */
  353.             kEFAULTErr                = E2OSStatus(EFAULT),            /* Bad address                            */
  354.             kEBUSYErr                = E2OSStatus(EBUSY),            /* Device or resource busy                */
  355.             kEEXISTErr                = E2OSStatus(EEXIST),            /* File exists                            */
  356.             kENODEVErr                = E2OSStatus(ENODEV),            /* No such device                        */
  357.             kEINVALErr                = E2OSStatus(EINVAL),            /* Invalid argument                        */
  358.             kENOTTYErr                = E2OSStatus(ENOTTY),            /* Not a character device                */
  359.             kEPIPEErr                = E2OSStatus(EPIPE),            /* Broken pipe                            */
  360.             kERANGEErr                = E2OSStatus(ERANGE),            /* Message size too large for STREAM    */
  361.             kEWOULDBLOCKErr            = E2OSStatus(EWOULDBLOCK),        /* Call would block, so was aborted        */
  362.             kEDEADLKErr                = E2OSStatus(EDEADLK),            /* or a deadlock would occur            */
  363.             kEALREADYErr            = E2OSStatus(EALREADY),
  364.             kENOTSOCKErr            = E2OSStatus(ENOTSOCK),            /* Socket operation on non-socket        */
  365.             kEDESTADDRREQErr        = E2OSStatus(EDESTADDRREQ),        /* Destination address required            */
  366.             kEMSGSIZEErr            = E2OSStatus(EMSGSIZE),            /* Message too long                        */
  367.             kEPROTOTYPEErr            = E2OSStatus(EPROTOTYPE),        /* Protocol wrong type for socket        */
  368.             kENOPROTOOPTErr            = E2OSStatus(ENOPROTOOPT),        /* Protocol not available                */
  369.             kEPROTONOSUPPORTErr     = E2OSStatus(EPROTONOSUPPORT),    /* Protocol not supported                */
  370.             kESOCKTNOSUPPORTErr     = E2OSStatus(ESOCKTNOSUPPORT), /* Socket type not supported            */
  371.             kEOPNOTSUPPErr            = E2OSStatus(EOPNOTSUPP),        /* Operation not supported on socket    */
  372.             kEADDRINUSEErr            = E2OSStatus(EADDRINUSE),        /* Address already in use                */
  373.             kEADDRNOTAVAILErr        = E2OSStatus(EADDRNOTAVAIL),    /* Can't assign requested address        */
  374.             kENETDOWNErr            = E2OSStatus(ENETDOWN),            /* Network is down                        */
  375.             kENETUNREACHErr            = E2OSStatus(ENETUNREACH),        /* Network is unreachable                */
  376.             kENETRESETErr            = E2OSStatus(ENETRESET),        /* Network dropped connection on reset    */
  377.             kECONNABORTEDErr        = E2OSStatus(ECONNABORTED),        /* Software caused connection abort        */
  378.             kECONNRESETErr            = E2OSStatus(ECONNRESET),        /* Connection reset by peer                */
  379.             kENOBUFSErr                = E2OSStatus(ENOBUFS),            /* No buffer space available            */
  380.             kEISCONNErr                = E2OSStatus(EISCONN),            /* Socket is already connected            */
  381.             kENOTCONNErr            = E2OSStatus(ENOTCONN),            /* Socket is not connected                */
  382.             kESHUTDOWNErr            = E2OSStatus(ESHUTDOWN),        /* Can't send after socket shutdown        */
  383.             kETOOMANYREFSErr        = E2OSStatus(ETOOMANYREFS),        /* Too many references: can't splice    */
  384.             kETIMEDOUTErr            = E2OSStatus(ETIMEDOUT),        /* Connection timed out                    */
  385.             kECONNREFUSEDErr        = E2OSStatus(ECONNREFUSED),        /* Connection refused                    */
  386.             kEHOSTDOWNErr            = E2OSStatus(EHOSTDOWN),        /* Host is down                            */
  387.             kEHOSTUNREACHErr        = E2OSStatus(EHOSTUNREACH),        /* No route to host                        */
  388.             kEPROTOErr                = E2OSStatus(EPROTO),
  389.             kETIMEErr                = E2OSStatus(ETIME),
  390.             kENOSRErr                = E2OSStatus(ENOSR),
  391.             kEBADMSGErr                = E2OSStatus(EBADMSG),
  392.             kECANCELErr                = E2OSStatus(ECANCEL),
  393.             kENOSTRErr                = E2OSStatus(ENOSTR),
  394.             kENODATAErr                = E2OSStatus(ENODATA),
  395.             kEINPROGRESSErr            = E2OSStatus(EINPROGRESS),
  396.             kESRCHErr                = E2OSStatus(ESRCH),
  397.             kENOMSGErr                = E2OSStatus(ENOMSG),
  398.             
  399.             kOTClientNotInittedErr        = E2OSStatus(ELASTERRNO + 1),
  400.             kOTPortHasDiedErr            = E2OSStatus(ELASTERRNO + 2),
  401.             kOTPortWasEjectedErr        = E2OSStatus(ELASTERRNO + 3),
  402.             kOTBadConfigurationErr        = E2OSStatus(ELASTERRNO + 4),
  403.             kOTConfigurationChangedErr    = E2OSStatus(ELASTERRNO + 5),
  404.             kOTUserRequestedErr            = E2OSStatus(ELASTERRNO + 6),
  405.             kOTPortLostConnection        = E2OSStatus(ELASTERRNO + 7)
  406.         };
  407.     
  408. /*    -------------------------------------------------------------------------
  409.     OTAddressType - defines the address type for the OTAddress
  410.     ------------------------------------------------------------------------- */
  411.  
  412.     typedef UInt16        OTAddressType;
  413.     
  414.     enum
  415.     {
  416.         kOTGenericName    = 0
  417.     };
  418.     
  419. /*    -------------------------------------------------------------------------
  420.     OTAddress - Generic OpenTransport protocol address
  421.     ------------------------------------------------------------------------- */
  422.  
  423.     struct OTAddress
  424.     {
  425.         OTAddressType    fAddressType;
  426.         UInt8            fAddress[1];
  427.     };
  428.     
  429.     typedef struct OTAddress    OTAddress;
  430.     
  431. /*    -------------------------------------------------------------------------
  432.     OTStructType - defines the structure type for the OTAlloc call
  433.     ------------------------------------------------------------------------- */
  434.  
  435.     typedef UInt32                OTStructType;
  436.     
  437.         enum
  438.         {
  439.             T_BIND            = (OTStructType)1,
  440.             T_OPTMGMT        = (OTStructType)2,
  441.             T_CALL            = (OTStructType)3,
  442.             T_DIS            = (OTStructType)4,
  443.             T_UNITDATA        = (OTStructType)5,
  444.             T_UDERROR        = (OTStructType)6,
  445.             T_INFO            = (OTStructType)7,
  446.             T_REPLYDATA        = (OTStructType)8,
  447.             T_REQUESTDATA    = (OTStructType)9,
  448.             T_UNITREQUEST    = (OTStructType)10,
  449.             T_UNITREPLY        = (OTStructType)11
  450.         };
  451.     
  452. /*    -------------------------------------------------------------------------
  453.     OTFlags - flags for sending and receiving data
  454.     ------------------------------------------------------------------------- */
  455.  
  456.     typedef UInt32                OTFlags;
  457.  
  458.         enum
  459.         {
  460.             T_MORE            = 0x001,    /* More data to come in message        */
  461.             T_EXPEDITED     = 0x002,    /* Data is expedited, if possible    */
  462.             T_ACKNOWLEDGED    = 0x004,    /* Acknowledge transaction            */
  463.             T_PARTIALDATA    = 0x008,    /* Partial data - more coming        */
  464.             T_NORECEIPT        = 0x010,    /* No event on transaction done        */
  465.             T_TIMEDOUT        = 0x020        /* Reply timed out                    */
  466.         };
  467.  
  468. /*    -------------------------------------------------------------------------
  469.     OTBand - a band value when reading priority messages
  470.     ------------------------------------------------------------------------- */
  471.  
  472.     typedef UInt32        OTBand;            /* A priority band value                    */
  473.  
  474. /*    -------------------------------------------------------------------------
  475.     Reference values
  476.     ------------------------------------------------------------------------- */
  477.  
  478. #ifdef __cplusplus
  479.     typedef struct TSTREAM*        StreamRef;
  480.     typedef struct TProvider*    ProviderRef;
  481.     typedef struct TEndpoint*    EndpointRef;
  482.     typedef struct TMapper*        MapperRef;
  483. #else
  484.     typedef void*                StreamRef;
  485.     typedef void*                ProviderRef;
  486.     typedef void*                EndpointRef;
  487.     typedef void*                MapperRef;
  488. #endif
  489.  
  490.     enum 
  491.     {
  492.         kOTInvalidRef            = 0
  493.     };
  494.     
  495.     #define kOTInvalidStreamRef        ((StreamRef)0)
  496.     #define kOTInvalidProviderRef    ((ProviderRef)0)
  497.     #define kOTInvalidEndpointRef    ((EndpointRef)0)
  498.     #define kOTInvalidMapperRef        ((MapperRef)0)
  499.  
  500. /*    -------------------------------------------------------------------------
  501.     OTEventCode values for Open Transport - These are the event codes that
  502.     are sent to notification routine during asynchronous processing.
  503.     ------------------------------------------------------------------------- */
  504.     
  505.     typedef UInt32    OTEventCode;
  506.     /*
  507.      * Function definition to handle notification from providers
  508.      */
  509.     typedef pascal void (*OTNotifyProcPtr)(void* contextPtr, OTEventCode code, 
  510.                                            OTResult result, void* cookie);
  511.  
  512.     enum
  513.     {
  514.         /*
  515.          * These will be returned by the T_LOOK function, or will be returned
  516.          * if asynchronous notification is used.
  517.          */
  518.         T_LISTEN                    = (OTEventCode)0x0001,        /* An connection request is available     */
  519.         T_CONNECT                    = (OTEventCode)0x0002,        /* Confirmation of a connect request    */ 
  520.         T_DATA                        = (OTEventCode)0x0004,        /* Standard data is available            */
  521.         T_EXDATA                    = (OTEventCode)0x0008,        /* Expedited data is available            */
  522.         T_DISCONNECT                = (OTEventCode)0x0010,        /* A disconnect is available            */
  523.         T_ERROR                     = (OTEventCode)0x0020,        /* obsolete/unused in library            */
  524.         T_UDERR                     = (OTEventCode)0x0040,        /* A Unit Data Error has occurred        */
  525.         T_ORDREL                    = (OTEventCode)0x0080,        /* An orderly release is available        */
  526.         T_GODATA                    = (OTEventCode)0x0100,        /* Flow control lifted on standard data    */
  527.         T_GOEXDATA                    = (OTEventCode)0x0200,        /* Flow control lifted on expedited data*/
  528.         T_REQUEST                    = (OTEventCode)0x0400,        /* An Incoming request is available        */
  529.         T_REPLY                        = (OTEventCode)0x0800,        /* An Incoming reply is available        */
  530.         T_PASSCON                     = (OTEventCode)0x1000,        /* State is now T_DATAXFER                */
  531.         T_RESET                     = (OTEventCode)0x2000,        /* Protocol has been reset                */
  532.  
  533.         /*
  534.          * kPRIVATEEVENT + 1 through kPRIVATEEVENT + 0xffff
  535.          *        may be used for any private event codes desired.
  536.          *        All other event codes are reserved for Apple Computer, Inc.
  537.          *        use only.
  538.          */
  539.         kPRIVATEEVENT                = (OTEventCode)0x10000000,
  540.         /*
  541.          * These are only returned if asynchronous notification is being used
  542.          */
  543.         kCOMPLETEEVENT                = (OTEventCode)0x20000000,
  544.         
  545.         T_BINDCOMPLETE                = (OTEventCode)0x20000001,    /* Bind call is complete                */    
  546.         T_UNBINDCOMPLETE            = (OTEventCode)0x20000002,    /* Unbind call is complete                */
  547.         T_ACCEPTCOMPLETE            = (OTEventCode)0x20000003,    /* Accept call is complete                */
  548.         T_REPLYCOMPLETE                = (OTEventCode)0x20000004,    /* SendReply call is complete            */
  549.         T_DISCONNECTCOMPLETE        = (OTEventCode)0x20000005,    /* Disconnect call is complete            */
  550.         T_OPTMGMTCOMPLETE            = (OTEventCode)0x20000006,    /* OptMgmt call is complete                */
  551.         T_OPENCOMPLETE                = (OTEventCode)0x20000007,    /* An Open call is complete                */
  552.         T_GETPROTADDRCOMPLETE        = (OTEventCode)0x20000008,    /* GetProtAddress call is complete        */
  553.         T_RESOLVEADDRCOMPLETE        = (OTEventCode)0x20000009,    /* A ResolveAddress call is complet        */
  554.         T_GETINFOCOMPLETE            = (OTEventCode)0x2000000A,    /* A GetInfo call is complete            */
  555.         T_SYNCCOMPLETE                = (OTEventCode)0x2000000B,    /* A Sync call is complete                */
  556.         T_MEMORYRELEASED            = (OTEventCode)0x2000000C,    /* No-copy memory was released            */
  557.         T_REGNAMECOMPLETE            = (OTEventCode)0x2000000D,    /* A RegisterName call is complete        */
  558.         T_DELNAMECOMPLETE            = (OTEventCode)0x2000000E,    /* A DeleteName call is complete        */
  559.         T_LKUPNAMECOMPLETE            = (OTEventCode)0x2000000F,    /* A LookupName call is complete        */
  560.         T_LKUPNAMERESULT            = (OTEventCode)0x20000010,    /* A LookupName is returning a name        */
  561.         kOTSyncIdleEvent            = (OTEventCode)0x20000011,    /* Synchronous call Idle event            */
  562.  
  563.         /*
  564.          * Events for streams - not normally seen by clients.
  565.          */
  566.         kSTREAMEVENT                = (OTEventCode)0x21000000,
  567.  
  568.         kGetmsgEvent                = (OTEventCode)0x21000002,    /* A GetMessage call is complete        */
  569.         kStreamReadEvent            = (OTEventCode)0x21000003,    /* A Read call is complete                */
  570.         kStreamWriteEvent            = (OTEventCode)0x21000004,    /* A Write call is complete                */
  571.         kStreamIoctlEvent            = (OTEventCode)0x21000005,    /* An Ioctl call is complete            */
  572.         kStreamOpenEvent            = (OTEventCode)0x21000007,    /* An OpenStream call is complete        */
  573.         kPollEvent                    = (OTEventCode)0x21000008,    /* A Poll call is complete                */
  574.     
  575.         kSIGNALEVENT                = (OTEventCode)0x22000000,    /* A signal has arrived from the STREAM    */
  576.         
  577.         kPROTOCOLEVENT                = (OTEventCode)0x23000000,    /* Some event from the protocols        */
  578.  
  579.         kIMMEDIATEEVENT                = (OTEventCode)0x80000000U,    /* This bit or'd in makes it "immediate"*/
  580.         /*
  581.          * These are miscellaneous events that could be sent to a provider
  582.          */
  583.         kOTProviderIsDisconnected    = (OTEventCode)0x23000001,    /* Provider is temporarily off-line        */
  584.         kOTProviderIsReconnected    = (OTEventCode)0x23000002,    /* Provider is now back on-line            */
  585.         /*
  586.          * These are system events sent to each provider.
  587.          */
  588.         kOTProviderWillClose        = (OTEventCode)0x24000001,    /* Provider will close immediately        */
  589.         kOTProviderIsClosed            = (OTEventCode)0x24000002,    /* Provider was closed                    */
  590.         /*
  591.          * These are system events sent to registered clients
  592.          */
  593.             //
  594.             // result code is 0, cookie is the OTPortRef
  595.             //
  596.         kOTPortDisabled                = (OTEventCode)0x25000001,    /* Port is now disabled                    */
  597.         kOTPortEnabled                = (OTEventCode)0x25000002,    /* Port is now enabled                    */
  598.         kOTRequestHardware            = (OTEventCode)0x25000003,    /* Request to use hardware                */
  599.         kOTHardwareInUse            = (OTEventCode)0x25000003,    /* specified hardware is in use            */
  600.         kOTReleaseHardware            = (OTEventCode)0x25000004,    /* Release use of hardware                */
  601.         kOTHardwareIsFree            = (OTEventCode)0x25000004,    /* specified hardware is no longer used    */
  602.             //
  603.             // result is a reason for the close request, cookie is a pointer to the 
  604.             // OTPortCloseStruct structure.
  605.             //
  606.         kOTClosePortRequest            = (OTEventCode)0x25000005,    /* Request to close                        */
  607.             //
  608.             // A new port has been registered, cookie is the OTPortRef
  609.             //
  610.         kOTNewPortRegistered        = (OTEventCode)0x25000006,    /* New port has been registered            */
  611.  
  612.         /*
  613.          * These are events sent to the configuration management infrastructure 
  614.          */
  615.         kOTConfigurationChanged        = (OTEventCode)0x26000001,    /* Protocol configuration changed        */
  616.         kOTSystemSleep                = (OTEventCode)0x26000002,
  617.         kOTSystemShutdown            = (OTEventCode)0x26000003,
  618.         kOTSystemAwaken                = (OTEventCode)0x26000004,
  619.         kOTSystemIdle                = (OTEventCode)0x26000005,
  620.         kOTSystemSleepPrep            = (OTEventCode)0x26000006,
  621.         kOTSystemShutdownPrep        = (OTEventCode)0x26000007,
  622.         kOTSystemAwakenPrep            = (OTEventCode)0x26000008
  623.     };
  624.     
  625.     #define IsOTPrivateEvent(x)            (((x) & 0x70000000L) == kPRIVATEEVENT)
  626.     #define IsOTCompleteEvent(x)        (((x) & 0x7f000000L) == kCOMPLETEEVENT)
  627.     #define IsOTStreamEvent(x)            (((x) & 0x7f000000L) == kSTREAMEVENT)
  628.     #define IsOTSignalEvent(x)            (((x) & 0x7f000000L) == kSIGNALEVENT)
  629.     #define IsOTProtocolEvent(x)        (((x) & 0x7f000000L) == kPROTOCOLEVENT)
  630.     #define IsOTImmediateEvent(x)        (((x) & 0x80000000L) != 0)
  631.     #define GetOTEventCode(x)            ((x) & ~kIMMEDIATEEVENT)
  632.     
  633. /*    -------------------------------------------------------------------------
  634.     Signals that are generated by a stream.  Add these values to
  635.     kSIGNALEVENT to determine what event you are receiving.
  636.     ------------------------------------------------------------------------- */
  637.     
  638.     enum
  639.     {
  640.         SIGHUP        = 1,
  641.         SIGURG        = 16,
  642.         SIGPOLL        = 30
  643.     };
  644.  
  645. /*    -------------------------------------------------------------------------
  646.     Option Management equates
  647.     ------------------------------------------------------------------------- */
  648.     /*
  649.     ** The XTI Level number of a protocol
  650.     */
  651.     typedef UInt32                OTXTILevel;
  652.     
  653.         enum
  654.         {
  655.             XTI_GENERIC     = (OTXTILevel)0xffff    /* level to match any protocol    */
  656.         };
  657.     /*
  658.     ** The XTI name of a protocol option
  659.     */
  660.     typedef UInt32                OTXTIName;
  661.         /*
  662.          * XTI names for options used with XTI_GENERIC above
  663.          */
  664.         enum
  665.         {
  666.             XTI_DEBUG        = (OTXTIName)0x0001,
  667.             XTI_LINGER        = (OTXTIName)0x0080,
  668.             XTI_RCVBUF        = (OTXTIName)0x1002,
  669.             XTI_RCVLOWAT    = (OTXTIName)0x1004,
  670.             XTI_SNDBUF        = (OTXTIName)0x1001,
  671.             XTI_SNDLOWAT    = (OTXTIName)0x1003,
  672.             XTI_PROTOTYPE    = (OTXTIName)0x1005
  673.         };
  674.         /*
  675.          * Generic options that can be used with any protocol
  676.          * that understands them
  677.          */
  678.         enum 
  679.         {
  680.             OPT_CHECKSUM    = (OTXTIName)0x0600,    // Set checksumming = UInt32 - 0 or 1)
  681.             OPT_RETRYCNT    = (OTXTIName)0x0601,    // Set a retry counter = UInt32 (0 = infinite)
  682.             OPT_INTERVAL    = (OTXTIName)0x0602,    // Set a retry interval = UInt32 milliseconds
  683.             OPT_ENABLEEOM    = (OTXTIName)0x0603,    // Enable the EOM indication = UInt8 (0 or 1)
  684.             OPT_SELFSEND    = (OTXTIName)0x0604,    // Enable Self-sending on broadcasts = UInt32 (0 or 1)
  685.             OPT_SERVERSTATUS= (OTXTIName)0x0605,    // Set Server Status (format is proto dependent)
  686.             OPT_ALERTENABLE    = (OTXTIName)0x0606,    // Enable/Disable protocol alerts
  687.             OPT_KEEPALIVE    = (OTXTIName)0x0008        // See t_keepalive structure
  688.         };
  689.  
  690. /*******************************************************************************
  691. ** Definitions not associated with a Typedef
  692. ********************************************************************************/
  693.  
  694. /*    -------------------------------------------------------------------------
  695.     IOCTL values for the OpenTransport system
  696.     ------------------------------------------------------------------------- */
  697.  
  698.     #define    MIOC_CMD(t,v)    ((((t)&0xFF) << 8) | ((v)&0xFF))
  699.  
  700.     enum
  701.     {
  702.         MIOC_STREAMIO    = 'A',        /* Basic Stream ioctl() cmds - I_PUSH, I_LOOK, etc. */
  703.         MIOC_STRLOG        = 'b',        /* ioctl's for Mentat's log device */
  704.         MIOC_SAD        = 'g',        /* ioctl's for Mentat's sad module */
  705.         MIOC_TCP        = 'k',        /* tcp.h ioctl's */
  706.         MIOC_DLPI        = 'l',        /* dlpi.h additions */
  707.         MIOC_OT            = 'O',        /* ioctls for Open Transport    */
  708.         MIOC_ATALK        = 'T',        /* ioctl's for AppleTalk    */
  709.         MIOC_SRL        = 'U',        /* ioctl's for Serial        */
  710.         MIOC_CFIG        = 'z'        /* ioctl's for private configuration */
  711.     };
  712.  
  713.     enum
  714.     {
  715.         I_OTGetMiscellaneousEvents    = ((MIOC_OT << 8) | 1),            /* sign up for Misc Events                    */
  716.         I_OTSetFramingType            = ((MIOC_OT << 8) | 2),            /* Set framing option for link                */
  717.             kOTGetFramingValue            = 0xffffffff,                /* Use this value to read framing            */
  718.         I_OTSetRawMode                = ((MIOC_OT << 8) | 3),            /* Set raw mode for link                    */
  719.         I_OTConnect                    = ((MIOC_OT << 8) | 4),            /* Generic connect request for links        */
  720.         I_OTDisconnect                = ((MIOC_OT << 8) | 5),            /* Generic disconnect request for links        */
  721.         I_OTScript                    = ((MIOC_OT << 8) | 6)            /* Send a script to a module                */
  722.     };
  723.     /*
  724.      * Structure for the I_OTScript Ioctl.
  725.      */
  726.     struct OTScriptInfo
  727.     {
  728.         UInt32    fScriptType;
  729.         void*    fTheScript;
  730.         UInt32    fScriptLength;
  731.     };
  732.         
  733. /*    -------------------------------------------------------------------------
  734.     Maximum size of a provider name, and maximum size of a STREAM module name.
  735.     This module name is smaller than the maximum size of a TProvider to allow
  736.     for 4 characters of extra "minor number" information that might be 
  737.     potentially in a TProvider name
  738.     ------------------------------------------------------------------------- */
  739.  
  740.     enum
  741.     {
  742.         kMaxModuleNameLength    = 31,
  743.         kMaxModuleNameSize        = kMaxModuleNameLength + 1,
  744.  
  745.         kMaxProviderNameLength    = kMaxModuleNameLength + 4,
  746.         kMaxProviderNameSize    = kMaxProviderNameLength + 1,
  747.         
  748.         kMaxSlotIDLength        = 7,
  749.         kMaxSlotIDSize            = 8,
  750.         
  751.         kMaxResourceInfoLength    = 31,
  752.         kMaxResourceInfoSize    = 32
  753.     };
  754.  
  755. /*    -------------------------------------------------------------------------
  756.     These values are used in the "fields" parameter of the OTAlloc call
  757.     to define which fields of the structure should be allocated.
  758.     ------------------------------------------------------------------------- */
  759.     
  760.     enum 
  761.     {
  762.         T_ADDR            = 0x01,
  763.         T_OPT            = 0x02,
  764.         T_UDATA         = 0x04,
  765.         T_ALL            = 0xffff
  766.     };
  767.     
  768. /*    -------------------------------------------------------------------------
  769.     These are the potential values returned by OTGetEndpointState and OTSync
  770.     which represent the state of an endpoint
  771.     ------------------------------------------------------------------------- */
  772.     
  773.     enum
  774.     {
  775.         T_UNINIT        = 0,    /* addition to standard xti.h    */
  776.         T_UNBND         = 1,    /* unbound                        */
  777.         T_IDLE            = 2,    /* idle                            */
  778.         T_OUTCON        = 3,    /* outgoing connection pending    */
  779.         T_INCON         = 4,    /* incoming connection pending    */
  780.         T_DATAXFER        = 5,    /* data transfer                */
  781.         T_OUTREL        = 6,    /* outgoing orderly release        */
  782.         T_INREL         = 7        /* incoming orderly release        */
  783.     };
  784.     
  785. /*    -------------------------------------------------------------------------
  786.     Flags used by option management calls to request services
  787.     ------------------------------------------------------------------------- */
  788.     
  789.     enum
  790.     {
  791.         T_NEGOTIATE     = 0x004,
  792.         T_CHECK         = 0x008,
  793.         T_DEFAULT        = 0x010,
  794.         T_CURRENT        = 0x080
  795.     };
  796.     
  797. /*    -------------------------------------------------------------------------
  798.     Flags used by option management calls to return results
  799.     ------------------------------------------------------------------------- */
  800.     
  801.     enum
  802.     {
  803.         T_SUCCESS        = 0x020,
  804.         T_FAILURE        = 0x040,
  805.         T_PARTSUCCESS    = 0x100,
  806.         T_READONLY        = 0x200,
  807.         T_NOTSUPPORT    = 0x400
  808.     };
  809.  
  810. /*    -------------------------------------------------------------------------
  811.     General definitions
  812.     ------------------------------------------------------------------------- */
  813.     
  814.     enum
  815.     {
  816.         T_YES            = 1,
  817.         T_NO            = 0,
  818.         T_UNUSED        = -1,
  819.         T_NULL            = 0,
  820.         T_ABSREQ        = 0x8000
  821.     };
  822.  
  823. /*    -------------------------------------------------------------------------
  824.     Option Management definitions
  825.     ------------------------------------------------------------------------- */
  826.  
  827.     enum
  828.     {
  829.         T_UNSPEC        = (~0 - 2),
  830.         T_ALLOPT        = 0
  831.     };
  832.     //
  833.     // This macro will align return the value of "len", rounded up to the next
  834.     // 4-byte boundary.
  835.     //
  836.     #define T_ALIGN(len)        (((UInt32)(len)+(sizeof(SInt32)-1)) & ~(sizeof(SInt32)-1))
  837.     //
  838.     // This macro will return the next option in the buffer, given the previous option
  839.     // in the buffer, returning NULL if there are no more.
  840.     // You start off by setting prevOption = (TOption*)theBuffer
  841.     // (Use OTNextOption for a more thorough check - it ensures the end
  842.     //  of the option is in the buffer as well.)
  843.     //
  844.     #define OPT_NEXTHDR(theBuffer, theBufLen, prevOption) \
  845.         (((char*)(prevOption) + T_ALIGN((prevOption)->len) < (char*)(theBuffer) + (theBufLen)) ?    \
  846.                 (TOption*)((char*)(prevOption)+T_ALIGN((prevOption)->len))    \
  847.                 : (TOption*)NULL)
  848.     
  849. /*******************************************************************************
  850. ** Structures and forward declarations
  851. **
  852. ** From here on down, all structures are aligned the same on 68K and powerpc
  853. ********************************************************************************/
  854.  
  855. /*    -------------------------------------------------------------------------
  856.     OTConfiguration structure - this is a "black box" structure used to
  857.     define the configuration of a provider or endpoint.
  858.     ------------------------------------------------------------------------- */
  859.  
  860.     struct OTConfiguration;
  861.     typedef struct OTConfiguration    OTConfiguration;
  862.  
  863.     #define kOTInvalidConfigurationPtr        ((OTConfiguration*)-1L)
  864.     #define kOTNoMemoryConfigurationPtr        ((OTConfiguration*)0)
  865.     
  866. /*    -------------------------------------------------------------------------
  867.     Option Management structures
  868.     ------------------------------------------------------------------------- */
  869.     /*
  870.      * Structure used with OPT_KEEPALIVE option.
  871.      */
  872.     struct t_kpalive
  873.     {
  874.         long    kp_onoff;        /* option on/off        */
  875.         long    kp_timeout;        /* timeout in minutes    */
  876.     };
  877.     typedef struct t_kpalive t_kpalive;
  878.     
  879.     /*
  880.      * Structure used with XTI_LINGER option
  881.      */
  882.     struct t_linger 
  883.     {
  884.         long    l_onoff;        /* option on/off */
  885.         long    l_linger;        /* linger time */
  886.     };
  887.     typedef struct t_linger t_linger;
  888.  
  889. /*    -------------------------------------------------------------------------
  890.     TEndpointInfo - this structure is returned from the GetEndpointInfo call
  891.     and contains information about an endpoint
  892.     ------------------------------------------------------------------------- */
  893.  
  894.     struct t_info
  895.     {
  896.         SInt32    addr;        /* Maximum size of an address            */
  897.         SInt32    options;    /* Maximum size of options                */
  898.         SInt32    tsdu;        /* Standard data transmit unit size        */
  899.         SInt32    etsdu;        /* Expedited data transmit unit size    */
  900.         SInt32    connect;    /* Maximum data size on connect            */
  901.         SInt32    discon;        /* Maximum data size on disconnect        */
  902.         UInt32    servtype;    /* service type (see below for values)    */
  903.         UInt32    flags;        /* Flags (see below for values)            */
  904.     };
  905.     
  906.     typedef struct t_info        TEndpointInfo;
  907.     
  908.     /*
  909.      * Values returned in servtype field of TEndpointInfo
  910.      */
  911.     enum
  912.     {
  913.         T_COTS            = 1,    /* Connection-mode service                                */
  914.         T_COTS_ORD        = 2,    /* Connection service with orderly release                */
  915.         T_CLTS            = 3,    /* Connectionless-mode service                            */
  916.         T_TRANS            = 5,    /* Connection-mode transaction service                    */
  917.         T_TRANS_ORD        = 6,    /* Connection transaction service with orderly release    */
  918.         T_TRANS_CLTS    = 7        /* Connectionless transaction service                    */
  919.     };
  920.     /*
  921.      * Values returned in flags field of TEndpointInfo
  922.      */
  923.     enum
  924.     {
  925.         T_SENDZERO            = 0x001,        /* supports 0-length TSDU's            */
  926.         T_XPG4_1            = 0x002,        /* supports the GetProtAddress call    */
  927.         T_CAN_SUPPORT_MDATA    = 0x10000000,        /* support M_DATAs on packet protocols    */
  928.         T_CAN_RESOLVE_ADDR    = 0x40000000,        /* Supports ResolveAddress call            */
  929.         T_CAN_SUPPLY_MIB    = 0x20000000        /* Supports SNMP MIB data                */
  930.     };
  931.     /*
  932.      * Values returned in tsdu, etsdu, connect, and discon fields of TEndpointInfo
  933.      */
  934.     enum
  935.     {
  936.         T_INFINITE        = -1,    /* supports infinit amounts of data        */
  937.         T_INVALID        = -2    /* Does not support data transmission    */
  938.     };
  939.     
  940. /*    -------------------------------------------------------------------------
  941.     OTPortRecord
  942.     ------------------------------------------------------------------------- */
  943.     /*
  944.      * Unique identifier for a port
  945.      */
  946.     typedef UInt32 OTPortRef;
  947.     
  948.     /*
  949.      * A couple of special values for the "port type" in an OTPortRef.
  950.      * See OpenTptLinks.h for other values.
  951.      * The device kOTPseudoDevice is used where no other defined
  952.      * device type will work.
  953.      */
  954.     enum
  955.     {
  956.         kOTNoDeviceType        = 0,
  957.         kOTPseudoDevice        = 1023,
  958.         kOTLastDeviceIndex    = 1022,
  959.         
  960.         kOTLastSlotNumber    = 255,
  961.         kOTLastOtherNumber    = 255
  962.     };
  963.  
  964.     /*
  965.      * kMaxPortNameLength is the maximum size allowed to define
  966.      * a port
  967.      */
  968.     enum
  969.     {
  970.         kMaxPortNameLength        = kMaxModuleNameLength + 4,
  971.         kMaxPortNameSize        = kMaxPortNameLength + 1
  972.     };
  973.  
  974.     enum
  975.     {
  976.         kInvalidPortRef        = ((OTPortRef)0),        /* %%% Going away */
  977.         kOTInvalidPortRef    = ((OTPortRef)0)
  978.     };
  979.     
  980.     /*
  981.      * Equates for the legal Bus-type values
  982.      */
  983.     enum
  984.     {
  985.         kOTUnknownBusPort    = 0,
  986.         kOTMotherboardBus    = 1,
  987.         kOTNuBus            = 2,
  988.         kOTPCIBus            = 3,
  989.         kOTGeoPort            = 4,
  990.         kOTPCMCIABus        = 5,
  991.         kOTLastBusIndex        = 15
  992.     };
  993.     
  994.     struct OTPortCloseStruct
  995.     {
  996.         OTPortRef            fPortRef;            // The port requested to be closed.
  997.         ProviderRef            fTheProvider;        // The provider using the port.
  998.         OSStatus            fDenyReason;        // Set to a negative number to deny the request
  999.     };
  1000.     
  1001.     typedef struct OTPortCloseStruct    OTPortCloseStruct;
  1002.     
  1003.     
  1004.     #ifdef __cplusplus
  1005.     extern "C" {
  1006.     #endif
  1007.     
  1008.     extern pascal OTPortRef    OTCreatePortRef(UInt8 busType, UInt16 devType,
  1009.                                             UInt16 slot, UInt16 other);
  1010.     extern pascal UInt16    OTGetDeviceTypeFromPortRef(OTPortRef ref);
  1011.     extern pascal UInt16    OTGetBusTypeFromPortRef(OTPortRef ref);
  1012.     extern pascal UInt16    OTGetSlotFromPortRef(OTPortRef ref, UInt16* other);
  1013.     
  1014.     
  1015.     #ifdef __cplusplus
  1016.     }
  1017.     #endif
  1018.         
  1019.     #define OTCreateNuBusPortRef(devType, slot, other)    \
  1020.         OTCreatePortRef(kOTNuBus, devType, slot, other)
  1021.         
  1022.     #define OTCreatePCIPortRef(devType, slot, other)    \
  1023.         OTCreatePortRef(kOTPCIBus, devType, slot, other)
  1024.         
  1025.     #define OTCreatePCMCIAPortRef(devType, slot, other)    \
  1026.         OTCreatePortRef(kOTPCMCIABus, devType, slot, other)
  1027.  
  1028.     /*    
  1029.      * One OTPortRecord is created for each instance of a port.
  1030.      * For Instance 'enet' identifies an ethernet port.
  1031.      * A TPortRecord for each ethernet card it finds, with an
  1032.      * OTPortRef that will uniquely allow the driver to determine which
  1033.      * port it is supposed to open on.
  1034.      */
  1035.     
  1036.     struct OTPortRecord
  1037.     {
  1038.         OTPortRef        fRef;
  1039.         UInt32            fPortFlags;
  1040.         UInt32            fInfoFlags;
  1041.         UInt32            fCapabilities;
  1042.         size_t            fNumChildPorts;
  1043.         OTPortRef*        fChildPorts;
  1044.         char            fPortName[kMaxProviderNameSize];
  1045.         char            fModuleName[kMaxModuleNameSize];
  1046.         char            fSlotID[kMaxSlotIDSize];
  1047.         char            fResourceInfo[kMaxResourceInfoSize];
  1048.         char            fReserved[164];
  1049.     };
  1050.     
  1051.     typedef struct OTPortRecord    OTPortRecord;
  1052.  
  1053.     /*
  1054.      * Values for the fInfoFlags field of OTPortRecord
  1055.      */
  1056.     enum
  1057.     {
  1058.         kOTPortIsDLPI                = 0x00000001,
  1059.         kOTPortIsTPI                = 0x00000002,
  1060.         kOTPortCanYield                = 0x00000004,
  1061.         kOTPortIsSystemRegistered    = 0x00004000,
  1062.         kOTPortIsPrivate            = 0x00008000,
  1063.         kOTPortIsAlias                = 0x80000000
  1064.     };
  1065.     /*
  1066.      * Values for the fPortFlags field of TPortRecord
  1067.      * If no bits are set, the port is currently inactive.
  1068.      * kOTPortIsDisabled and kOTPortIsUnavailable may be set
  1069.      * at the same time.  
  1070.      */
  1071.     enum
  1072.     {
  1073.         kOTPortIsActive                = 0x00000001,
  1074.         kOTPortIsDisabled             = 0x00000002,
  1075.         kOTPortIsUnavailable        = 0x00000004
  1076.     };
  1077.     
  1078. /*    -------------------------------------------------------------------------
  1079.     TOptionHeader and TOption
  1080.     
  1081.     This structure describes the contents of a single option in a buffer
  1082.     ------------------------------------------------------------------------- */
  1083.  
  1084.     struct TOptionHeader
  1085.     {
  1086.             UInt32        len;        /* total length of option                */
  1087.                                     /* = sizeof(TOptionHeader) + length        */
  1088.                                     /*     of option value in bytes            */
  1089.             OTXTILevel    level;        /* protocol affected                    */
  1090.             OTXTIName    name;        /* option name                            */
  1091.             UInt32        status;     /* status value                            */
  1092.     };
  1093.  
  1094.     typedef struct TOptionHeader    TOptionHeader;
  1095.     
  1096.     struct TOption
  1097.     {
  1098.             UInt32        len;        /* total length of option                */
  1099.                                     /* = sizeof(TOption) + length    */
  1100.                                     /*     of option value in bytes            */
  1101.             OTXTILevel    level;        /* protocol affected                    */
  1102.             OTXTIName    name;        /* option name                            */
  1103.             UInt32        status;     /* status value                            */
  1104.             UInt32        value[1];    /* data goes here                        */
  1105.     };
  1106.     
  1107.     typedef struct TOption    TOption;
  1108.     
  1109.     enum
  1110.     {
  1111.         kOTOptionHeaderSize            = sizeof(TOptionHeader),
  1112.         kOTBooleanOptionDataSize    = sizeof(UInt32),
  1113.         kOTBooleanOptionSize        = kOTOptionHeaderSize + kOTBooleanOptionDataSize,
  1114.         kOTOneByteOptionSize        = kOTOptionHeaderSize + 1,
  1115.         kOTTwoByteOptionSize        = kOTOptionHeaderSize + 2,
  1116.         kOTFourByteOptionSize        = kOTOptionHeaderSize + sizeof(UInt32)
  1117.     };
  1118.  
  1119. /*    -------------------------------------------------------------------------
  1120.     PollRef structure
  1121.     
  1122.     This is used with the OTStreamPoll function
  1123.     ------------------------------------------------------------------------- */
  1124.  
  1125.     struct PollRef 
  1126.     {
  1127.         int             filler;
  1128.         short        events;
  1129.         short        revents;
  1130.         StreamRef     ref;
  1131.     };
  1132.     
  1133.     typedef struct PollRef    PollRef;
  1134.  
  1135. /*    -------------------------------------------------------------------------
  1136.     OTClientList structure
  1137.     
  1138.     This is used with the OTYieldPortRequest function.
  1139.     ------------------------------------------------------------------------- */
  1140.  
  1141.     struct OTClientList
  1142.     {
  1143.         size_t        fNumClients;
  1144.         UInt8        fBuffer[4];
  1145.     };
  1146.     
  1147.     typedef struct OTClientList    OTClientList;
  1148.  
  1149. /*    -------------------------------------------------------------------------
  1150.     OTData
  1151.     
  1152.     This is a structure that may be used in a TNetbuf or netbuf to send
  1153.     non-contiguous data.  Set the 'len' field of the netbuf to the
  1154.     constant kNetbufDataIsOTData to signal that the 'buf' field of the
  1155.     netbuf actually points to one of these structures instead of a
  1156.     memory buffer.
  1157.     ------------------------------------------------------------------------- */
  1158.  
  1159.     struct OTData
  1160.     {
  1161.             void*        fNext;
  1162.             void*        fData;
  1163.             size_t        fLen;
  1164.     };
  1165.     
  1166.     typedef struct OTData    OTData;
  1167.     
  1168.     enum
  1169.     {
  1170.         kNetbufDataIsOTData    = (size_t)0xfffffffeU
  1171.     };
  1172.     
  1173. /*    -------------------------------------------------------------------------
  1174.     OTBuffer
  1175.  
  1176.     This is the structure that is used for no-copy receives.
  1177.     When you are done with it, you must call the OTReleaseBuffer function.
  1178.     For best performance, you need to call OTReleaseBuffer quickly.  Only
  1179.     data netbufs may use this - no netbufs for addresses or options, or the like.
  1180.     ------------------------------------------------------------------------- */
  1181.  
  1182. typedef struct OTBuffer    OTBuffer;
  1183.  
  1184. struct OTBuffer
  1185. {
  1186.         void*        fLink;        // b_next & b_prev
  1187.         void*        fLink2;
  1188.         OTBuffer*    fNext;        // b_cont
  1189.         UInt8*        fData;        // b_rptr
  1190.         size_t        fLen;        // b_wptr
  1191.         void*        fSave;        // b_datap
  1192.         UInt8        fBand;        // b_band
  1193.         UInt8        fType;        // b_pad1
  1194.         UInt8        fPad1;
  1195.         UInt8        fFlags;        // b_flag
  1196. };
  1197.  
  1198. /*    -------------------------------------------------------------------------
  1199.     OTBufferInfo
  1200.     
  1201.     This structure is used with OTReadBuffer to keep track of where you
  1202.     are in the buffer, since the OTBuffer is "read-only".
  1203.     ------------------------------------------------------------------------- */
  1204.     
  1205.     struct OTBufferInfo
  1206.     {
  1207.         OTBuffer*    fBuffer;
  1208.         size_t        fOffset;
  1209.         UInt8        fPad;
  1210.     };
  1211.     
  1212.     typedef struct OTBufferInfo    OTBufferInfo;
  1213.     
  1214.     #define OTInitBufferInfo(infoPtr, theBuffer)    \
  1215.         (infoPtr)->fBuffer = theBuffer;                \
  1216.         (infoPtr)->fPad    = (theBuffer)->fPad1;        \
  1217.         (infoPtr)->fOffset    = 0
  1218.     
  1219.     enum
  1220.     {
  1221.         kOTNetbufDataIsOTBufferStar    = (size_t)0xfffffffdU
  1222.     };
  1223.  
  1224. /*    -------------------------------------------------------------------------
  1225.     TNetbuf
  1226.     
  1227.     This structure is the basic structure used to pass data back and forth
  1228.     between the Open Transport protocols and their clients
  1229.     ------------------------------------------------------------------------- */
  1230.  
  1231.     struct TNetbuf
  1232.     {
  1233.         size_t    maxlen;
  1234.         size_t    len;
  1235.         UInt8*    buf;
  1236.     };
  1237.     
  1238.     typedef struct TNetbuf    TNetbuf;
  1239.     
  1240. /*    -------------------------------------------------------------------------
  1241.     TBind
  1242.     
  1243.     Structure passed to GetProtAddress, ResolveAddress and Bind
  1244.     ------------------------------------------------------------------------- */
  1245.  
  1246.     struct TBind
  1247.     {
  1248.         TNetbuf    addr;
  1249.         OTQLen    qlen;
  1250.     };
  1251.     
  1252.     typedef struct TBind    TBind;
  1253.     
  1254. /*    -------------------------------------------------------------------------
  1255.     TDiscon
  1256.     
  1257.     Structure passed to RcvDisconnect to find out additional information
  1258.     about the disconnect
  1259.     ------------------------------------------------------------------------- */
  1260.  
  1261.     struct TDiscon
  1262.     {
  1263.         TNetbuf        udata;
  1264.         OTReason    reason;
  1265.         OTSequence     sequence;
  1266.     };
  1267.     
  1268.     typedef struct TDiscon    TDiscon;
  1269.     
  1270.  
  1271. /*    -------------------------------------------------------------------------
  1272.     TCall
  1273.     
  1274.     Structure passed to Connect, RcvConnect, Listen, Accept, and
  1275.     SndDisconnect to describe the connection.
  1276.     ------------------------------------------------------------------------- */
  1277.  
  1278.     struct TCall
  1279.     {
  1280.         TNetbuf        addr;
  1281.         TNetbuf        opt;
  1282.         TNetbuf        udata;
  1283.         OTSequence     sequence;
  1284.     };
  1285.     
  1286.     typedef struct TCall    TCall;
  1287.     
  1288. /*    -------------------------------------------------------------------------
  1289.     TUnitData
  1290.     
  1291.     Structure passed to SndUData and RcvUData to describe the datagram
  1292.     ------------------------------------------------------------------------- */
  1293.  
  1294.     struct TUnitData
  1295.     {
  1296.         TNetbuf            addr;
  1297.         TNetbuf            opt;
  1298.         TNetbuf            udata;
  1299.     };
  1300.     
  1301.     typedef struct TUnitData    TUnitData;
  1302.     
  1303. /*    -------------------------------------------------------------------------
  1304.     TUDErr
  1305.     
  1306.     Structure passed to RcvUDErr to find out about a datagram error
  1307.     ------------------------------------------------------------------------- */
  1308.  
  1309.     struct TUDErr
  1310.     {
  1311.         TNetbuf            addr;
  1312.         TNetbuf            opt;
  1313.         SInt32            error;
  1314.     };
  1315.     
  1316.     typedef struct TUDErr    TUDErr;
  1317.     
  1318. /*    -------------------------------------------------------------------------
  1319.     TOptMgmt
  1320.     
  1321.     Structure passed to the OptionManagement call to read or set protocol
  1322.     options.
  1323.     ------------------------------------------------------------------------- */
  1324.  
  1325.     struct TOptMgmt
  1326.     {
  1327.         TNetbuf            opt;
  1328.         OTFlags            flags;
  1329.     };
  1330.     
  1331.     typedef struct TOptMgmt    TOptMgmt;
  1332.     
  1333. /*    -------------------------------------------------------------------------
  1334.     TRequest
  1335.     
  1336.     Structure passed to SndRequest and RcvRequest that contains the information
  1337.     about the request
  1338.     ------------------------------------------------------------------------- */
  1339.  
  1340.     struct TRequest
  1341.     {
  1342.         TNetbuf            data;
  1343.         TNetbuf            opt;
  1344.         OTSequence        sequence;
  1345.     };
  1346.     
  1347.     typedef struct TRequest    TRequest;
  1348.     
  1349. /*    -------------------------------------------------------------------------
  1350.     TReply
  1351.     
  1352.     Structure passed to SndReply to send a reply to an incoming request
  1353.     ------------------------------------------------------------------------- */
  1354.  
  1355.     struct TReply
  1356.     {
  1357.         TNetbuf            data;
  1358.         TNetbuf            opt;
  1359.         OTSequence        sequence;
  1360.     };
  1361.     
  1362.     typedef struct TReply    TReply;
  1363.     
  1364. /*    -------------------------------------------------------------------------
  1365.     TUnitRequest
  1366.     
  1367.     Structure passed to SndURequest and RcvURequest that contains the information
  1368.     about the request
  1369.     ------------------------------------------------------------------------- */
  1370.  
  1371.     struct TUnitRequest
  1372.     {
  1373.         TNetbuf            addr;
  1374.         TNetbuf            opt;
  1375.         TNetbuf            udata;
  1376.         OTSequence        sequence;
  1377.     };
  1378.     
  1379.     typedef struct TUnitRequest    TUnitRequest;
  1380.     
  1381. /*    -------------------------------------------------------------------------
  1382.     TUnitReply
  1383.     
  1384.     Structure passed to SndUReply to send a reply to an incoming request
  1385.     ------------------------------------------------------------------------- */
  1386.     
  1387.     struct TUnitReply
  1388.     {
  1389.         TNetbuf            opt;
  1390.         TNetbuf            udata;
  1391.         OTSequence        sequence;
  1392.     };
  1393.     
  1394.     typedef struct TUnitReply    TUnitReply;
  1395.     
  1396. /*    -------------------------------------------------------------------------
  1397.     TRegisterRequest
  1398.     ------------------------------------------------------------------------- */
  1399.  
  1400.     struct TRegisterRequest
  1401.     {
  1402.         TNetbuf        name;
  1403.         TNetbuf        addr;
  1404.         OTFlags        flags;
  1405.     };
  1406.     
  1407.     typedef struct TRegisterRequest    TRegisterRequest;
  1408.     
  1409. /*    -------------------------------------------------------------------------
  1410.     TRegisterReply
  1411.     ------------------------------------------------------------------------- */
  1412.  
  1413.     struct TRegisterReply
  1414.     {
  1415.         TNetbuf        addr;
  1416.         OTNameID    nameid;
  1417.     };
  1418.     
  1419.     typedef struct TRegisterReply    TRegisterReply;
  1420.     
  1421. /*    -------------------------------------------------------------------------
  1422.     TLookupRequest
  1423.     ------------------------------------------------------------------------- */
  1424.  
  1425.     struct TLookupRequest
  1426.     {
  1427.         TNetbuf        name;
  1428.         TNetbuf        addr;
  1429.         UInt32        maxcnt;
  1430.         OTTimeout    timeout;
  1431.         OTFlags        flags;
  1432.     };
  1433.     
  1434.     typedef struct TLookupRequest    TLookupRequest;
  1435.  
  1436. /*    -------------------------------------------------------------------------
  1437.     TLookupReply 
  1438.     
  1439.     Structure used by Mapper protocols to return the results of name Lookups
  1440.     ------------------------------------------------------------------------- */
  1441.     /*
  1442.      * This is the structure returned by the mapper for names that are
  1443.      * looked up.  
  1444.      */
  1445.      
  1446.     struct TLookupBuffer
  1447.     {
  1448.         UInt16        fAddressLength;
  1449.         UInt16        fNameLength;
  1450.         UInt8        fAddressBuffer[1];
  1451.     };
  1452.     
  1453.     typedef struct TLookupBuffer    TLookupBuffer;
  1454.     
  1455.     #define OTNextLookupBuffer(buf)            \
  1456.         ((TLookupBuffer*)                    \
  1457.             ((char*)buf + ((offsetof(TLookupBuffer, fAddressBuffer) + buf->fAddressLength + buf->fNameLength + 3) & ~3)))
  1458.  
  1459.     struct TLookupReply
  1460.     {
  1461.         TNetbuf            names;
  1462.         UInt32            rspcount;
  1463.     };
  1464.     
  1465.     typedef struct TLookupReply    TLookupReply;
  1466.  
  1467. /*******************************************************************************
  1468. ** C Interfaces to Open Transport
  1469. ********************************************************************************/
  1470.  
  1471. #ifdef __cplusplus
  1472. extern "C" {
  1473. #endif
  1474.  
  1475. /*    -------------------------------------------------------------------------
  1476.     Initializing and shutting down Open Transport
  1477.     ------------------------------------------------------------------------- */
  1478.     
  1479. #if !OTKERNEL
  1480.  
  1481. extern pascal OSStatus    InitOpenTransport(void);
  1482. extern pascal OSStatus    InitOpenTransportUtilities(void);
  1483. extern pascal void        CloseOpenTransport(void);
  1484. //
  1485. // This registers yourself as a client for any miscellaneous Open Transport
  1486. // notifications that come along. CloseOpenTransport will automatically do
  1487. // an OTUnregisterAsClient, if you have not already done so.
  1488. //
  1489. extern pascal OSStatus    OTRegisterAsClient(OTClientName name, OTNotifyProcPtr proc);
  1490. extern pascal OSStatus    OTUnregisterAsClient(void);
  1491.  
  1492. #endif    /* !OTKERNEL    */
  1493.  
  1494. /*    -------------------------------------------------------------------------
  1495.     Interrupt processing
  1496.     
  1497.     These routine must be used by interrupt, deferred task, vbl, and time
  1498.     manager routines to bracket any calls to OpenTransport.
  1499.     ------------------------------------------------------------------------- */
  1500.  
  1501.     extern pascal void        OTEnterInterrupt(void);
  1502.     extern pascal void        OTLeaveInterrupt(void);
  1503.  
  1504.     typedef pascal void (*OTProcessProcPtr)(void* arg);
  1505.     
  1506.     extern pascal long        OTCreateDeferredTask(OTProcessProcPtr proc, void* arg);
  1507.     extern pascal Boolean    OTScheduleDeferredTask(long dtCookie);
  1508.     extern pascal Boolean    OTScheduleInterruptTask(long dtCookie);
  1509.     extern pascal OSStatus    OTDestroyDeferredTask(long dtCookie);
  1510.  
  1511. #if !OTKERNEL
  1512.  
  1513.     extern pascal long        OTCreateSystemTask(OTProcessProcPtr proc, void* arg);
  1514.     extern pascal OSStatus    OTDestroySystemTask(long stCookie);
  1515.     extern pascal Boolean    OTScheduleSystemTask(long stCookie);
  1516.     extern pascal Boolean    OTCancelSystemTask(long stCookie);
  1517.     extern pascal Boolean    OTCanMakeSyncCall();
  1518.     
  1519. #endif    /* !OTKERNEL    */
  1520.  
  1521. /*    -------------------------------------------------------------------------
  1522.     Functions for dealing with port
  1523.     ------------------------------------------------------------------------- */
  1524.  
  1525. #if !OTKERNEL
  1526.  
  1527. extern pascal Boolean    OTGetIndexedPort(OTPortRecord* record, size_t index);
  1528. extern pascal Boolean    OTFindPort(OTPortRecord* record, const char* portName);
  1529. extern pascal Boolean    OTFindPortByRef(OTPortRecord* record, OTPortRef ref);
  1530.  
  1531. #endif    /* !OTKERNEL    */
  1532.  
  1533. /*    -------------------------------------------------------------------------
  1534.     Interface to providers
  1535.     ------------------------------------------------------------------------- */
  1536.  
  1537. #if !OTKERNEL
  1538.  
  1539. extern pascal OSStatus        OTCloseProvider(ProviderRef ref);
  1540. extern pascal ProviderRef    OTTransferProviderOwnership(ProviderRef ref, 
  1541.                                                         OTClient prevOwner,
  1542.                                                         OSStatus* errPtr);
  1543. extern pascal OTClient    OTWhoAmI(void);
  1544. extern pascal OTPortRef    OTGetProviderPortRef(ProviderRef ref);
  1545. extern pascal SInt32    OTIoctl(ProviderRef ref, UInt32 cmd, void* data);
  1546. extern pascal OTResult    OTGetMessage(ProviderRef ref, struct strbuf* ctlbuf,
  1547.                                      struct strbuf* databuf, OTFlags*);
  1548. extern pascal OTResult    OTGetPriorityMessage(ProviderRef ref, struct strbuf* ctlbuf,
  1549.                                              struct strbuf* databuf, OTBand*, OTFlags*);
  1550. extern pascal OSStatus    OTPutMessage(ProviderRef ref, const struct strbuf* ctlbuf,
  1551.                                      const struct strbuf* databuf, OTFlags flags);
  1552. extern pascal OSStatus    OTPutPriorityMessage(ProviderRef ref, const struct strbuf* ctlbuf,
  1553.                                              const struct strbuf* databuf, OTBand, OTFlags);
  1554. extern pascal OSStatus    OTSetAsynchronous(ProviderRef ref);
  1555. extern pascal OSStatus    OTSetSynchronous(ProviderRef ref);
  1556. extern pascal Boolean    OTIsSynchronous(ProviderRef ref);
  1557. extern pascal OSStatus    OTSetBlocking(ProviderRef ref);
  1558. extern pascal OSStatus    OTSetNonBlocking(ProviderRef ref);
  1559. extern pascal Boolean    OTIsBlocking(ProviderRef ref);
  1560. extern pascal OSStatus    OTInstallNotifier(ProviderRef ref,
  1561.                                           OTNotifyProcPtr proc, void* contextPtr);
  1562. extern pascal OSStatus    OTUseSyncIdleEvents(ProviderRef ref, Boolean useEvents);
  1563. #if FOR_SYSTEM8_PREEMPTIVE
  1564. extern pascal OSStatus    OTInstallPreemptiveNotifier(ProviderRef ref,
  1565.                                                     OTNotifyProcPtr proc, void* contextPtr);
  1566. #endif
  1567. extern pascal void        OTRemoveNotifier(ProviderRef ref);
  1568. extern pascal OSStatus    OTAckSends(ProviderRef ref);
  1569. extern pascal OSStatus    OTDontAckSends(ProviderRef ref);
  1570. extern pascal Boolean    OTIsAckingSends(ProviderRef ref);
  1571. extern pascal OSStatus    OTCancelSynchronousCalls(ProviderRef ref, OSStatus err);
  1572.  
  1573. #define OTIsNonBlocking(ref)    (!OTIsBlocking(ref))
  1574. #define OTIsAsynchronous(ref)    (!OTIsSynchronous(ref))
  1575.  
  1576. #endif    /* !OTKERNEL    */
  1577.  
  1578. /*    -------------------------------------------------------------------------
  1579.     Interface to endpoints
  1580.     ------------------------------------------------------------------------- */
  1581.  
  1582. #if !OTKERNEL
  1583. //
  1584. // Open/Close
  1585. //
  1586. extern pascal EndpointRef    OTOpenEndpoint(OTConfiguration* config, OTOpenFlags oflag,
  1587.                                            TEndpointInfo* info, OSStatus* err);
  1588. extern pascal OSStatus        OTAsyncOpenEndpoint(OTConfiguration* config,
  1589.                                                 OTOpenFlags oflag, TEndpointInfo* info,
  1590.                                                 OTNotifyProcPtr proc, void* contextPtr);
  1591. //
  1592. // Misc Information
  1593. //
  1594. extern pascal OSStatus    OTGetEndpointInfo(EndpointRef ref, TEndpointInfo* info);
  1595. extern pascal OTResult    OTGetEndpointState(EndpointRef ref);
  1596. extern pascal OTResult    OTLook(EndpointRef ref);
  1597. extern pascal OTResult    OTSync(EndpointRef ref);
  1598. extern pascal OTResult    OTCountDataBytes(EndpointRef ref, size_t* countPtr);
  1599. extern pascal OSStatus    OTGetProtAddress(EndpointRef ref, TBind* boundAddr,
  1600.                                          TBind* peerAddr);
  1601. extern pascal OSStatus    OTResolveAddress(EndpointRef ref, TBind* reqAddr,
  1602.                                          TBind* retAddr, OTTimeout timeOut);
  1603. //
  1604. // Allocating structures
  1605. //
  1606. extern pascal void*        OTAlloc(EndpointRef ref, OTStructType structType,
  1607.                                 UInt32 fields, OSStatus* err);
  1608. extern pascal OTResult    OTFree(void* ptr, OTStructType structType);
  1609. //
  1610. // Option management
  1611. //
  1612. extern pascal OSStatus    OTOptionManagement(EndpointRef ref, TOptMgmt* req, TOptMgmt* ret);
  1613. //
  1614. // Bind/Unbind
  1615. //
  1616. extern pascal OSStatus    OTBind(EndpointRef ref, TBind* reqAddr, TBind* retAddr);
  1617. extern pascal OSStatus    OTUnbind(EndpointRef ref);
  1618. //
  1619. // Connection creation/tear-down
  1620. //
  1621. extern pascal OSStatus    OTConnect(EndpointRef ref, TCall* sndCall, TCall* rcvCall);
  1622. extern pascal OSStatus    OTRcvConnect(EndpointRef ref, TCall* call);
  1623. extern pascal OSStatus    OTListen(EndpointRef ref, TCall* call);
  1624. extern pascal OSStatus    OTAccept(EndpointRef ref, EndpointRef resRef, TCall* call);
  1625. extern pascal OSStatus    OTSndDisconnect(EndpointRef ref, TCall* call);
  1626. extern pascal OSStatus    OTSndOrderlyDisconnect(EndpointRef ref);
  1627. extern pascal OSStatus    OTRcvDisconnect(EndpointRef ref, TDiscon* discon);
  1628. extern pascal OSStatus    OTRcvOrderlyDisconnect(EndpointRef ref);
  1629. //
  1630. // Connection-oriented send/receive
  1631. //
  1632. extern pascal OTResult    OTRcv(EndpointRef ref, void* buf, size_t nbytes, OTFlags* flags);
  1633. extern pascal OTResult    OTSnd(EndpointRef ref, void* buf, size_t nbytes, OTFlags flags);
  1634. //
  1635. // non-connection oriented send/receive
  1636. //
  1637. extern pascal OSStatus    OTSndUData(EndpointRef ref, TUnitData* udata);
  1638. extern pascal OSStatus    OTRcvUData(EndpointRef ref, TUnitData* udata, OTFlags* flags);
  1639. extern pascal OSStatus    OTRcvUDErr(EndpointRef ref, TUDErr* uderr);
  1640. //
  1641. // Connection-oriented transactions
  1642. //
  1643. extern pascal OSStatus    OTSndRequest(EndpointRef ref, TRequest* req, OTFlags reqFlags);
  1644. extern pascal OSStatus    OTRcvReply(EndpointRef ref, TReply* reply, OTFlags* replyFlags);
  1645. extern pascal OSStatus    OTSndReply(EndpointRef ref, TReply* reply, OTFlags replyFlags);
  1646. extern pascal OSStatus    OTRcvRequest(EndpointRef ref, TRequest* req, OTFlags* reqFlags);
  1647. extern pascal OSStatus    OTCancelRequest(EndpointRef ref, OTSequence sequence);
  1648. extern pascal OSStatus    OTCancelReply(EndpointRef ref, OTSequence sequence);
  1649. //
  1650. // Connectionless transactions
  1651. //
  1652. extern pascal OSStatus    OTSndURequest(EndpointRef ref, TUnitRequest* req, OTFlags reqFlags);
  1653. extern pascal OSStatus    OTRcvUReply(EndpointRef ref, TUnitReply* reply, OTFlags* replyFlags);
  1654. extern pascal OSStatus    OTSndUReply(EndpointRef ref, TUnitReply* reply, OTFlags replyFlags);
  1655. extern pascal OSStatus    OTRcvURequest(EndpointRef ref, TUnitRequest* req, OTFlags* reqFlags);
  1656. extern pascal OSStatus    OTCancelURequest(EndpointRef ref, OTSequence seq);
  1657. extern pascal OSStatus    OTCancelUReply(EndpointRef ref, OTSequence seq);
  1658.  
  1659. /*    -------------------------------------------------------------------------
  1660.     Interface to mappers
  1661.     ------------------------------------------------------------------------- */
  1662.  
  1663. extern pascal OSStatus     OTAsyncOpenMapper(OTConfiguration* config, OTOpenFlags oflag,
  1664.                                           OTNotifyProcPtr proc, void* contextPtr);            
  1665. extern pascal MapperRef    OTOpenMapper(OTConfiguration* config, OTOpenFlags oflag,
  1666.                                      OSStatus* err);    
  1667. extern pascal OSStatus    OTRegisterName(MapperRef ref, TRegisterRequest* req,
  1668.                                        TRegisterReply* reply);
  1669. extern pascal OSStatus    OTDeleteName(MapperRef ref, TNetbuf* name);
  1670. extern pascal OSStatus    OTDeleteNameByID(MapperRef ref, OTNameID nameID);
  1671. extern pascal OSStatus    OTLookupName(MapperRef ref, TLookupRequest* req,
  1672.                                      TLookupReply* reply);
  1673.  
  1674. /*    -------------------------------------------------------------------------
  1675.     Miscellaneous and generic functions
  1676.     ------------------------------------------------------------------------- */
  1677.  
  1678. extern void*            OTAllocMem(size_t);
  1679. extern void                OTFreeMem(void*);
  1680. extern pascal void        OTDelay(UInt32 seconds);
  1681. extern pascal void        OTIdle(void);
  1682.  
  1683. #define sleep(x)    OTDelay(x)
  1684. #define delay(x)    OTDelay(x)
  1685.  
  1686. extern pascal OTConfiguration*    
  1687.                 OTCreateConfiguration(const char* path);
  1688. extern pascal OTConfiguration*
  1689.                 OTCloneConfiguration(OTConfiguration* cfig);
  1690. extern pascal void    OTDestroyConfiguration(OTConfiguration* cfig);
  1691. extern pascal OSStatus    OTCreateOptions(const char* endPtName, char** strPtr,
  1692.                                         TNetbuf* buf);
  1693. extern pascal OSStatus    OTCreateOptionString(const char* endPtName, TOption** opt,
  1694.                                          void* bufEnd, char* string,
  1695.                                          size_t stringSize);
  1696.  
  1697. extern pascal OSStatus    OTNextOption(UInt8* buffer, UInt32 buflen,
  1698.                                      TOption** prevOptPtr);
  1699. extern pascal TOption*    OTFindOption(UInt8* buffer, UInt32 buflen,
  1700.                                      OTXTILevel level, OTXTIName name); 
  1701.         
  1702. #endif    /* !OTKERNEL    */
  1703.  
  1704. #ifdef __cplusplus
  1705. }
  1706. #endif
  1707.  
  1708. /*******************************************************************************
  1709. ** Open Transport Utility routines
  1710. **
  1711. ** These routines are available to both client and kernel
  1712. ********************************************************************************/
  1713.  
  1714. /*    -------------------------------------------------------------------------
  1715.     ** Memory functions
  1716.     ------------------------------------------------------------------------- */
  1717.  
  1718. #ifdef __cplusplus
  1719. extern "C" {
  1720. #endif
  1721.  
  1722. void    OTMemcpy(void* dest, const void* src, size_t nBytes);
  1723. Boolean    OTMemcmp(const void* mem1, const void* mem2, size_t nBytes);
  1724. void    OTMemmove(void* dest, const void* src, size_t nBytes);
  1725. void    OTMemzero(void* dest, size_t nBytes);
  1726. void    OTMemset(void* dest, uchar_p toSet, size_t nBytes);
  1727. size_t    OTStrLength(const char*);
  1728. void    OTStrCopy(char*, const char*);
  1729. void    OTStrCat(char*, const char*);
  1730. Boolean    OTStrEqual(const char*, const char*);
  1731.  
  1732. #ifdef __cplusplus
  1733. }
  1734. #endif
  1735.  
  1736. /*    -------------------------------------------------------------------------
  1737.     ** Time functions
  1738.     **    
  1739.     **    OTGetTimeStamp returns time in "tick" numbers, stored in 64 bits.
  1740.     **    This timestamp can be used as a base number for calculating elapsed 
  1741.     **    time.
  1742.     **    OTSubtractTimeStamps returns a pointer to the "result" parameter.
  1743.     **        
  1744.     **    OTGetClockTimeInSecs returns time since Open Transport was initialized
  1745.     **        in seconds.
  1746.     ------------------------------------------------------------------------- */
  1747.     
  1748.     typedef UnsignedWide    OTTimeStamp;
  1749.     
  1750. #ifdef __cplusplus
  1751. extern "C" {
  1752. #endif
  1753.  
  1754.     void            OTGetTimeStamp(OTTimeStamp*);
  1755.     OTTimeStamp*    OTSubtractTimeStamps(OTTimeStamp* result, OTTimeStamp* start,
  1756.                                          OTTimeStamp* end);
  1757.     UInt32            OTTimeStampInMilliseconds(OTTimeStamp* delta);
  1758.     UInt32            OTTimeStampInMicroseconds(OTTimeStamp* delta);
  1759.     UInt32            OTElapsedMilliseconds(OTTimeStamp* startTime);
  1760.     UInt32            OTElapsedMicroseconds(OTTimeStamp* startTime);
  1761.  
  1762.     UInt32            OTGetClockTimeInSecs(void);
  1763.  
  1764. #ifdef __cplusplus
  1765. }
  1766. #endif
  1767.  
  1768. /*    -------------------------------------------------------------------------
  1769.     ** OTLIFO
  1770.     **
  1771.     ** These are functions to implement a LIFO list that is interrupt-safe.
  1772.     ** The only function which is not is OTReverseList.  Normally, you create
  1773.     ** a LIFO list, populate it at interrupt time, and then use OTLIFOStealList
  1774.     ** to atomically remove the list, and OTReverseList to flip the list so that
  1775.     ** it is a FIFO list, which tends to be more useful.
  1776.     ------------------------------------------------------------------------- */
  1777.  
  1778.     typedef struct OTLink    OTLink;
  1779.     typedef struct OTLIFO    OTLIFO;
  1780.  
  1781.     struct OTLink
  1782.     {
  1783.         OTLink*    fNext;
  1784.         
  1785.     #ifdef __cplusplus
  1786.                 void    Init()
  1787.                             { fNext = NULL; }
  1788.     #endif
  1789.     };
  1790.     
  1791.     #ifdef __cplusplus
  1792.     extern "C" {
  1793.     #endif
  1794.         //
  1795.         // This function puts "object" on the listHead, and places the
  1796.         // previous value at listHead into the pointer at "object" plus
  1797.         // linkOffset.
  1798.         //
  1799.     void    OTEnqueue(void** listHead, void* object, size_t linkOffset);
  1800.         //
  1801.         // This function returns the head object of the list, and places
  1802.         // the pointer at "object" + linkOffset into the listHead
  1803.         //
  1804.     void*    OTDequeue(void** listHead, size_t linkOffset);
  1805.         //
  1806.         // This function atomically enqueues the link onto the list
  1807.         //
  1808.     void     OTLIFOEnqueue(OTLIFO* list, OTLink* link);
  1809.         //
  1810.         // This function atomically dequeues the first element
  1811.         // on the list
  1812.         //
  1813.     OTLink* OTLIFODequeue(OTLIFO* list);
  1814.         //
  1815.         // This function atomically empties the list and returns a
  1816.         // pointer to the first element on the list
  1817.         //
  1818.     OTLink*    OTLIFOStealList(OTLIFO* list);
  1819.         //
  1820.         // This function reverses a list that was stolen by
  1821.         // OTLIFOStealList.  It is NOT atomic.  It returns the
  1822.         // new starting list.
  1823.         //
  1824.     OTLink*    OTReverseList(OTLink*);
  1825.         //
  1826.         // This function atomically steals the LIFO, then reverses it.
  1827.         //
  1828.     OTLink*    OTLIFOStealAndReverseList(OTLIFO* list);
  1829.     
  1830.     #ifdef __cplusplus
  1831.     }
  1832.     #endif
  1833.     
  1834.     struct OTLIFO
  1835.     {
  1836.         OTLink*    fHead;
  1837.         
  1838.     #ifdef __cplusplus
  1839.                     void    Init()    
  1840.                                 { fHead = NULL; }
  1841.                     
  1842.                     void    Enqueue(OTLink* link)
  1843.                                 { OTLIFOEnqueue(this, link); }
  1844.                                 
  1845.                     OTLink*    Dequeue()
  1846.                                 { return OTLIFODequeue(this); }
  1847.                                 
  1848.                     OTLink*    StealList()
  1849.                                 { return OTLIFOStealList(this); }
  1850.                                 
  1851.                     Boolean    IsEmpty()
  1852.                                 { return fHead == NULL; }
  1853.     #endif
  1854.     };
  1855.  
  1856. /*    -------------------------------------------------------------------------
  1857.     ** OTList
  1858.     **
  1859.     ** An OTList is a non-interrupt-safe list, but has more features than the
  1860.     ** OTLIFO list. It is a standard singly-linked list.
  1861.     ------------------------------------------------------------------------- */
  1862.  
  1863.     typedef struct OTList    OTList;
  1864.     
  1865.     typedef Boolean (* _CDECL OTListSearchProcPtr)(const void* ref, OTLink* linkToCheck);
  1866.     
  1867.     #ifdef __cplusplus
  1868.     extern "C" {
  1869.     #endif
  1870.         //
  1871.         // Add the link to the list at the front
  1872.         //
  1873.     void         OTAddFirst(OTList* list, OTLink* link);
  1874.         //
  1875.         // Add the link to the list at the end
  1876.         //
  1877.     void         OTAddLast(OTList* list, OTLink* link);
  1878.         //
  1879.         // Remove the first link from the list
  1880.         //
  1881.     OTLink*        OTRemoveFirst(OTList* list);
  1882.         //
  1883.         // Remove the last link from the list
  1884.         //
  1885.     OTLink*        OTRemoveLast(OTList* list);
  1886.         //
  1887.         // Return the first link from the list
  1888.         //
  1889.     OTLink*        OTGetFirst(OTList* list);
  1890.         //
  1891.         // Return the last link from the list
  1892.         //
  1893.     OTLink*        OTGetLast(OTList* list);
  1894.         //
  1895.         // Return true if the link is present in the list
  1896.         //
  1897.     Boolean        OTIsInList(OTList* list, OTLink* link);
  1898.         //
  1899.         // Find a link in the list which matches the search criteria
  1900.         // established by the search proc and the refPtr.  This is done
  1901.         // by calling the search proc, passing it the refPtr and each
  1902.         // link in the list, until the search proc returns true.
  1903.         // NULL is returned if the search proc never returned true.
  1904.         //
  1905.     OTLink*        OTFindLink(OTList* list, OTListSearchProcPtr proc, const void* refPtr);
  1906.         //
  1907.         // Remove the specified link from the list, returning true if it was found
  1908.         //
  1909.     Boolean        OTRemoveLink(OTList*, OTLink*);
  1910.         //
  1911.         // Similar to OTFindLink, but it also removes it from the list.
  1912.         //
  1913.     OTLink*        OTFindAndRemoveLink(OTList* list, OTListSearchProcPtr proc, const void* refPtr);
  1914.         //
  1915.         // Return the "index"th link in the list
  1916.         //
  1917.     OTLink*        OTGetIndexedLink(OTList* list, size_t index);
  1918.     
  1919.     #ifdef __cplusplus
  1920.     }
  1921.     #endif
  1922.     
  1923.     struct OTList
  1924.     {
  1925.         OTLink*        fHead;
  1926.         
  1927.     #ifdef __cplusplus
  1928.                 void        Init()    
  1929.                                 { fHead = NULL; }
  1930.                 
  1931.                 Boolean        IsEmpty()
  1932.                                 { return fHead == NULL; }
  1933.                                 
  1934.                 void        AddFirst(OTLink* link)
  1935.                                 { OTAddFirst(this, link); }
  1936.                 
  1937.                 void        AddLast(OTLink* link)
  1938.                                 { OTAddLast(this, link); }
  1939.                 
  1940.                 OTLink*        GetFirst()
  1941.                                 { return OTGetFirst(this); }
  1942.                 
  1943.                 OTLink*        GetLast()
  1944.                                 { return OTGetLast(this); }
  1945.                 
  1946.                 OTLink*        RemoveFirst()
  1947.                                 { return OTRemoveFirst(this); }
  1948.                 
  1949.                 OTLink*        RemoveLast()
  1950.                                 { return OTRemoveLast(this); }
  1951.                                 
  1952.                 Boolean        IsInList(OTLink* link)
  1953.                                 { return OTIsInList(this, link); }
  1954.                                 
  1955.                 OTLink*        FindLink(OTListSearchProcPtr proc, const void* ref)
  1956.                                 { return OTFindLink(this, proc, ref); }
  1957.                                 
  1958.                 Boolean        RemoveLink(OTLink* link)
  1959.                                 { return OTRemoveLink(this, link); }
  1960.                                 
  1961.                 OTLink*        RemoveLink(OTListSearchProcPtr proc, const void* ref)
  1962.                                 { return OTFindAndRemoveLink(this, proc, ref); }
  1963.                                 
  1964.                 OTLink*        GetIndexedLink(size_t index)
  1965.                                 { return OTGetIndexedLink(this, index); }
  1966.     #endif
  1967.     };
  1968.     
  1969.     #define OTGetLinkObject(link, struc, field)    \
  1970.         ((struc*)((char*)(link) - offsetof(struc, field)))
  1971.  
  1972. /*    -------------------------------------------------------------------------
  1973.     ** Atomic Operations
  1974.     **
  1975.     ** The Bit operations return the previous value of the bit (0 or non-zero).
  1976.     ** The memory pointed to must be a single byte and only bits 0 through 7 are
  1977.     ** valid.  Bit 0 corresponds to a mask of 0x01, and Bit 7 to a mask of 0x80.
  1978.     ------------------------------------------------------------------------- */
  1979.  
  1980. typedef UInt8    OTLock;
  1981.  
  1982. #ifdef __cplusplus
  1983. extern "C" {
  1984. #endif
  1985.  
  1986. #if GENERATING68K
  1987.  
  1988.     #pragma parameter __D0 OTAtomicSetBit(__A0, __D0)
  1989.     Boolean OTAtomicSetBit(UInt8*, size_t) =
  1990.     {
  1991.         0x01d0, 0x56c0,    /* bset.b d0,(a0); sne d0 */
  1992.         0x7201, 0xc081    /* moveq #1,d1; and.l d1,d0 */
  1993.     };
  1994.         
  1995.     #pragma parameter __D0 OTAtomicClearBit(__A0, __D0)
  1996.     Boolean OTAtomicClearBit(UInt8*, size_t) =
  1997.     {
  1998.         0x0190, 0x56c0,    /* bclr.b d0,(a0); sne d0 */
  1999.         0x7201, 0xc081    /* moveq #1,d1; and.l d1,d0 */
  2000.     };
  2001.         
  2002.     #pragma parameter __D0 OTAtomicTestBit(__A0, __D0)
  2003.     Boolean OTAtomicTestBit(UInt8*, size_t) =
  2004.     {
  2005.         0x0110, 0x56c0,    /* btst.b d0,(a0); sne d0 */
  2006.         0x7201, 0xc081    /* moveq #1,d1; and.l d1,d0 */
  2007.     };
  2008.     
  2009.     #pragma parameter __D0 OTCompareAndSwapPtr(__D0, __D1, __A0)
  2010.     Boolean OTCompareAndSwapPtr(void*, void*, void**) =
  2011.     {
  2012.         0x0ed0, 0x0040,        /*    cas.l    d0,d1,(a0)    */
  2013.         0x57c0,                /*    seq        d0            */
  2014.         0x7201, 0xc081        /* moveq #1,d1; and.l d1,d0 */
  2015.     };
  2016.  
  2017.     #pragma parameter __D0 OTCompareAndSwap32(__D0, __D1, __A0)
  2018.     Boolean OTCompareAndSwap32(UInt32, UInt32, UInt32*) =
  2019.     {
  2020.         0x0ed0, 0x0040,        /*    cas.l    d0,d1,(a0)    */
  2021.         0x57c0,                /*    seq        d0            */
  2022.         0x7201, 0xc081        /* moveq #1,d1; and.l d1,d0 */
  2023.     };
  2024.     
  2025.     #pragma parameter __D0 OTCompareAndSwap16(__D0, __D1, __A0)
  2026.     Boolean OTCompareAndSwap16(UInt32, UInt32, UInt16*) =
  2027.     {
  2028.         0x0cd0, 0x0040,        /*    cas.w    d0,d1,(a0)    */
  2029.         0x57c0,                /*    seq        d0            */
  2030.         0x7201, 0xc081        /* moveq #1,d1; and.l d1,d0 */
  2031.     };
  2032.     
  2033.     #pragma parameter __D0 OTCompareAndSwap8(__D0, __D1, __A0)
  2034.     Boolean OTCompareAndSwap8(UInt32, UInt32, UInt8*) =
  2035.     {
  2036.         0x0ad0, 0x0040,        /*    cas.b    d0,d1,(a0)    */
  2037.         0x57c0,                /*    seq        d0            */
  2038.         0x7201, 0xc081        /* moveq #1,d1; and.l d1,d0 */
  2039.     };
  2040.  
  2041.     #pragma parameter __D0 OTAtomicAdd32(__D0, __A0)
  2042.     SInt32 OTAtomicAdd32(SInt32, SInt32*) =
  2043.     {
  2044.         0x2240,                /*         move.l    d0,a1        */
  2045.         0x2210,                /*@1    move.l    (a0),d1        */
  2046.         0x2001,                /*        move.l    d1,d0        */
  2047.         0xd089,                /*        add.l    a1,d0        */
  2048.         0x0ed0, 0x0001,        /*        cas.l    d1,d0,(a0)    */
  2049.         0x66f4                /*        bne.s    @1            */
  2050.     };
  2051.         
  2052. #elif GENERATINGPOWERPC
  2053.  
  2054.     Boolean OTAtomicSetBit(UInt8*, size_t);
  2055.     Boolean OTAtomicClearBit(UInt8*, size_t);
  2056.     Boolean OTAtomicTestBit(UInt8*, size_t);
  2057.     //
  2058.     // WARNING! void* and UInt32 locations MUST be on 4-byte boundaries.
  2059.     //            UInt16 locations must not cross a 4-byte boundary.
  2060.     //
  2061.     Boolean    OTCompareAndSwapPtr(void* oldValue, void* newValue, void** location);
  2062.     Boolean    OTCompareAndSwap32(UInt32 oldValue, UInt32 newValue, UInt32* location);
  2063.     Boolean    OTCompareAndSwap16(UInt32 oldValue, UInt32 newValue, UInt16* location);
  2064.     Boolean    OTCompareAndSwap8(UInt32 oldValue, UInt32 newValue, UInt8* location);
  2065.     //
  2066.     // WARNING! UInt32 locations MUST be on 4-byte boundaries.
  2067.     //            UInt16 locations must not cross a 4-byte boundary.
  2068.     //
  2069.     SInt32    OTAtomicAdd32(SInt32, SInt32*);
  2070.  
  2071. #endif
  2072.  
  2073.     SInt16    OTAtomicAdd16(SInt32, SInt16*);
  2074.     SInt8    OTAtomicAdd8(SInt32, SInt8*);
  2075.  
  2076.     Boolean    OTAcquireLock(OTLock*);
  2077.     void    OTClearLock(OTLock*);
  2078.     
  2079.     #define OTClearLock(lockPtr)    *(lockPtr) = 0
  2080.     #define OTAcquireLock(lockPtr)    (OTAtomicSetBit(lockPtr, 0) == 0)
  2081.  
  2082. #ifdef __cplusplus
  2083. }
  2084. #endif
  2085.  
  2086.  
  2087. /*******************************************************************************
  2088. ** Timer functions
  2089. **
  2090. ** These APIs have NO MIXED-MODE GLUE.  They may only be used from the 
  2091. ** Native mode,
  2092. ********************************************************************************/
  2093.  
  2094. #if !OTKERNEL
  2095. #ifdef __cplusplus
  2096. extern "C" {
  2097. #endif
  2098.  
  2099. pascal long        OTCreateTimerTask(OTProcessProcPtr proc, void* arg);
  2100. pascal Boolean    OTCancelTimerTask(long timerTask);
  2101. pascal void        OTDestroyTimerTask(long timerTask);
  2102. pascal Boolean    OTScheduleTimerTask(long timerTask, OTTimeout milliSeconds);
  2103.  
  2104. #ifdef __cplusplus
  2105. }
  2106. #endif
  2107. #endif
  2108.  
  2109. /*******************************************************************************
  2110. ** Port functions
  2111. **
  2112. ** These APIs have NO MIXED-MODE GLUE.  They may only be used from the 
  2113. ** Native mode,
  2114. ********************************************************************************/
  2115.  
  2116. #ifdef __cplusplus
  2117. extern "C" {
  2118. #endif
  2119.  
  2120.     //
  2121.     // Register a port. The name the port was registered under is returned in
  2122.     // the fPortName field.
  2123.     //
  2124. OSStatus    OTRegisterPort(OTPortRecord* portInfo, void* ref);
  2125.     //
  2126.     // Unregister the port with the given name (If you re-register the
  2127.     // port, it may get a different name - use OTChangePortState if
  2128.     // that is not desireable).  Since a single OTPortRef can be registered
  2129.     // with several names, the API needs to use the portName rather than
  2130.     // the OTPortRef to disambiguate.
  2131.     //
  2132. OSStatus    OTUnregisterPort(const char* portName, void**);
  2133.     //
  2134.     // Change the state of the port.
  2135.     //
  2136. OSStatus    OTChangePortState(OTPortRef, OTEventCode theChange, OTResult why);
  2137.  
  2138. #if !OTKERNEL    /* These aren't available to the kernel */
  2139.     //
  2140.     // Returns a buffer containing all of the clients that refused to yield the port.
  2141.     // "size" is the total number of bytes @ buffer, including the fNumClients field.
  2142.     //
  2143. OSStatus    OTYieldPortRequest(ProviderRef, OTPortRef, OTClientList* buffer, size_t size);
  2144.     //
  2145.     // Send a notification to all Open Transport registered clients
  2146.     //
  2147. void        OTNotifyAllClients(OTEventCode, OTResult, void* cookie);
  2148.  
  2149. #endif
  2150.  
  2151. #ifdef __cplusplus
  2152. }
  2153. #endif
  2154.  
  2155. /*******************************************************************************
  2156. ** Miscellaneous helpful functions
  2157. **
  2158. ** These APIs have NO MIXED-MODE GLUE.  They may only be used from the 
  2159. ** Native mode,
  2160. ********************************************************************************/
  2161.  
  2162. #if !OTKERNEL
  2163. #ifdef __cplusplus
  2164. extern "C" {
  2165. #endif
  2166.  
  2167. Boolean            StoreIntoNetbuf(TNetbuf*, void*, long);
  2168. Boolean            StoreMsgIntoNetbuf(TNetbuf*, OTBuffer* buf);
  2169. void            OTReleaseBuffer(OTBuffer*);
  2170. size_t            OTBufferDataSize(OTBuffer*);
  2171.  
  2172. Boolean            OTReadBuffer(OTBufferInfo*, void*, size_t*);
  2173.  
  2174. #ifdef __cplusplus
  2175. }
  2176. #endif
  2177. #endif
  2178.  
  2179. /*******************************************************************************
  2180. ** STREAM APIs
  2181. **
  2182. ** These APIs have NO MIXED-MODE GLUE.  They may only be used from the 
  2183. ** Native mode,
  2184. ********************************************************************************/
  2185.  
  2186. struct strbuf;        /* #include <stropts.h> to get the definition */
  2187.  
  2188. /*    -------------------------------------------------------------------------
  2189.     Autopush information
  2190.     
  2191.     The autopush functionality for Open Transport is based on the names of
  2192.     devices and modules, rather than on the major number information like 
  2193.     SVR4.  This is so that autopush information can be set up for modules
  2194.     that are not yet loaded.
  2195.     ------------------------------------------------------------------------- */
  2196.     /*
  2197.      * This is the name of the stream module you open and send the 
  2198.      * IOCTL modules to.
  2199.      */
  2200.     #define kSADModuleName    "sad"
  2201.     
  2202.     enum
  2203.     {
  2204.         kOTAutopushMax    = 8,
  2205.         
  2206.         I_SAD_SAP        = MIOC_CMD(MIOC_SAD, 1),    /* Set autopush information        */
  2207.         I_SAD_GAP        = MIOC_CMD(MIOC_SAD, 2),    /* Get autopush information        */
  2208.         I_SAD_VML        = MIOC_CMD(MIOC_SAD, 3)        /* Validate a list of modules 
  2209.                                                         (uses str_list structure
  2210.                                                          in stropts.h)                */
  2211.     };
  2212.  
  2213. /*                                                                this line deleted for release disk
  2214.  * This structure must match the strapush structure in sad.h    this line deleted for release disk
  2215.  * This includes the kOTAutopushMax constant above                this line deleted for release disk
  2216.  */                                                            /*    this line deleted for release disk */
  2217. struct OTAutopushInfo            /* Ioctl structure used for SAD_SAP and SAD_GAP commands */
  2218. {
  2219.     unsigned int    sap_cmd;
  2220.     char            sap_device_name[kMaxModuleNameSize];
  2221.     long            sap_minor;
  2222.     long            sap_lastminor;
  2223.     long            sap_npush;
  2224.     char            sap_list[kOTAutopushMax][kMaxModuleNameSize];
  2225. };
  2226.  
  2227. typedef struct OTAutopushInfo    OTAutopushInfo;
  2228.  
  2229. /*
  2230.  * Command values for sap_cmd
  2231.  */
  2232.  
  2233. enum
  2234. {
  2235.     kSAP_ONE            = 1,    /* Configure a single minor device            */
  2236.     kSAP_RANGE            = 2,    /* Configure a range of minor devices        */
  2237.     kSAP_ALL            = 3,    /* Configure all minor devices                */
  2238.     kSAP_CLEAR            = 4        /* Clear autopush information                */
  2239. };
  2240.  
  2241. /*    -------------------------------------------------------------------------
  2242.     The functions
  2243.     ------------------------------------------------------------------------- */
  2244.  
  2245. #if !OTKERNEL
  2246. #ifdef __cplusplus
  2247. extern "C" {
  2248. #endif
  2249.  
  2250. pascal StreamRef    OTStreamOpen(const char* name, OTOpenFlags, OSStatus*);
  2251. pascal OSStatus        OTAsyncStreamOpen(const char* name, OTOpenFlags,
  2252.                                       OTNotifyProcPtr, void* contextPtr);
  2253. pascal OTResult        OTStreamPoll(PollRef* fds, UInt32 nfds, OTTimeout timeout);
  2254. pascal OTResult        OTAsyncStreamPoll(PollRef* fds, UInt32 nfds, OTTimeout timeout,
  2255.                                     OTNotifyProcPtr, void* contextPtr);
  2256.  
  2257. pascal OSStatus        OTStreamClose(StreamRef);
  2258. pascal OTResult        OTStreamRead(StreamRef, void* buf, size_t len);
  2259. pascal OTResult        OTStreamWrite(StreamRef, void* buf, size_t len);
  2260. pascal OTResult        OTStreamIoctl(StreamRef, UInt32 type, void* data);
  2261. pascal OTResult        OTStreamPipe(StreamRef*);
  2262. pascal void            OTStreamSetBlocking(StreamRef);
  2263. pascal void            OTStreamSetNonBlocking(StreamRef);
  2264. pascal Boolean        OTStreamIsBlocking(StreamRef);
  2265. pascal void            OTStreamSetSynchronous(StreamRef);
  2266. pascal void            OTStreamSetAsynchronous(StreamRef);
  2267. pascal Boolean        OTStreamIsSynchronous(StreamRef);
  2268. pascal OTResult        OTStreamGetMessage(StreamRef, struct strbuf* ctlbuf,
  2269.                                  struct strbuf* databuf, OTFlags*);
  2270. pascal OTResult        OTStreamGetPriorityMessage(StreamRef, struct strbuf* ctlbuf,
  2271.                                          struct strbuf* databuf, OTBand*, OTFlags*);
  2272. pascal OSStatus        OTStreamPutMessage(StreamRef, const struct strbuf* ctlbuf,
  2273.                                  const struct strbuf* databuf, OTFlags flags);
  2274. pascal OSStatus        OTStreamPutPriorityMessage(StreamRef, const struct strbuf* ctlbuf,
  2275.                                          const struct strbuf* databuf, OTBand, OTFlags);
  2276. pascal OSStatus        OTInstallStreamNotifier(StreamRef, OTNotifyProcPtr, void* contextPtr);
  2277. pascal OSStatus        OTStreamUseSyncIdleEvents(StreamRef, Boolean useEvents);
  2278. /*
  2279.  * Opening endpoints and mappers on a Stream - these calls are synchronous, and may
  2280.  * only be used at System Task time. Once the stream has been installed into a provider
  2281.  * or endpoint, you should not continue to use STREAMS APIs on it
  2282.  */
  2283. pascal ProviderRef    OTOpenProviderOnStream(StreamRef, OSStatus*);
  2284. pascal EndpointRef    OTOpenEndpointOnStream(StreamRef, OSStatus*);
  2285.  
  2286. #ifdef __cplusplus
  2287. }
  2288. #endif
  2289. #endif
  2290.  
  2291. /*******************************************************************************
  2292. **
  2293. ** FROM HERE ON DOWN ARE THE C++ Interfaces to Open Transport
  2294. **
  2295. ********************************************************************************/
  2296.  
  2297. #ifdef __cplusplus
  2298.  
  2299. /*
  2300.  * Set up whether we use the SingleObject class or not for C++
  2301.  */
  2302. #if GENERATING68K && !defined(__SC__) && !defined(THINK_CPLUS)
  2303.     #define USESINGLEOBJECT    1
  2304. #else
  2305.     #define USESINGLEOBJECT    0
  2306. #endif
  2307. /*
  2308.  * If we're using Symantec compilers, we need to force a dummy virtual function at
  2309.  * the front of the vtable to get alignment with Apple MPW compilers.
  2310.  */
  2311. #define EXTRA_VTABLE_SLOT
  2312. #if defined(__SC__) || defined(THINK_CPLUS) || defined(__MRC__)
  2313.         #if !NoDummyVTableSlot
  2314.             #undef EXTRA_VTABLE_SLOT
  2315.             #define EXTRA_VTABLE_SLOT                                \
  2316.                 private:                                        \
  2317.                     virtual        void DummyVirtualFunction();
  2318.         #endif
  2319. #endif
  2320. /*
  2321.  * Define a constructor and destructor define
  2322.  */
  2323. #define _CT                _MDECL
  2324. #define _DT                ~ _MDECL
  2325.  
  2326. /*
  2327.  * Some forward declarations
  2328.  */
  2329.      struct    StateRecord;
  2330.     struct    XmitRecord;
  2331.     struct    OTBuffer;
  2332.  
  2333. /*    -------------------------------------------------------------------------
  2334.     CLASS TProvider
  2335.     
  2336.     This class provides the client interface to a Stream.  Typically, clients
  2337.     talk to an object (or glue code in front of the object) that is a subclass
  2338.     of TProvider.
  2339.     ------------------------------------------------------------------------- */
  2340.  
  2341. #if !OTKERNEL
  2342.  
  2343.     class TProvider
  2344.     {
  2345.         private:
  2346.             void*        operator new(size_t)    { return NULL; }
  2347.             void        operator delete(void*)    {}
  2348.             
  2349.         //
  2350.         // This is the public interface to a TProvider.  All other public
  2351.         // methods normally come from the subclass.
  2352.         //
  2353.         public:    
  2354.             OSStatus    Close()                { return OTCloseProvider(this); }
  2355.  
  2356.             OSStatus    SetNonBlocking()    { return OTSetNonBlocking(this); }
  2357.             OSStatus    SetBlocking()        { return OTSetBlocking(this); }
  2358.             Boolean        IsBlocking()        { return OTIsBlocking(this); }
  2359.             Boolean        IsNonBlocking()        { return !OTIsBlocking(this); }
  2360.             OSStatus    SetSynchronous()    { return OTSetSynchronous(this); }
  2361.             OSStatus    SetAsynchronous()    { return OTSetAsynchronous(this); }
  2362.             Boolean        IsSynchronous()        { return OTIsSynchronous(this); }
  2363.             Boolean        IsAsynchronous()    { return !OTIsSynchronous(this); }
  2364.             
  2365.             OSStatus    AckSends()            { return OTAckSends(this); }
  2366.             OSStatus    DontAckSends()        { return OTDontAckSends(this); }
  2367.             Boolean        IsAckingSends()        { return OTIsAckingSends(this); }
  2368.     
  2369.             void        CancelSynchronousCalls(OSStatus err)
  2370.                         { (void)OTCancelSynchronousCalls(this, err); }
  2371.     
  2372.             OSStatus    InstallNotifier(OTNotifyProcPtr proc, void* ptr)
  2373.                         { return OTInstallNotifier(this, proc, ptr); }
  2374.         #if FOR_SYSTEM8_PREEMPTIVE
  2375.             OSStatus    InstallPreemptiveNotifier(OTNotifyProcPtr proc, void* ptr)
  2376.                         { return OTInstallPreemptiveNotifier(this, proc, ptr); }
  2377.         #endif
  2378.  
  2379.             OSStatus    UseSyncIdleEvents()
  2380.                         { return OTUseSyncIdleEvents(this, true); }
  2381.  
  2382.             OSStatus    DontUseSyncIdleEvents()
  2383.                         { return OTUseSyncIdleEvents(this, false); }
  2384.                         
  2385.             void        RemoveNotifier()
  2386.                         { OTRemoveNotifier(this); }
  2387.             
  2388.             OTPortRef    GetOTPortRef()
  2389.                         { return OTGetProviderPortRef(this); }
  2390.                         
  2391.             ProviderRef    TransferOwnership(OTClient prevOwner, OSStatus* errPtr)
  2392.                         { return OTTransferProviderOwnership(this, prevOwner, errPtr); }
  2393.                         
  2394.             SInt32        Ioctl(UInt32 cmd, void* data)
  2395.                         { return OTIoctl(this, cmd, data); }
  2396.             SInt32        Ioctl(UInt32 cmd, long data)
  2397.                         { return OTIoctl(this, cmd, (void*)data); }
  2398.                         
  2399.             OTResult    GetMessage(struct strbuf* ctlbuf, struct strbuf* databuf, OTFlags* flagPtr)
  2400.                         { return OTGetMessage(this, ctlbuf, databuf, flagPtr); }
  2401.             OTResult    GetPriorityMessage(struct strbuf* ctlbuf, struct strbuf* databuf,
  2402.                                            OTBand* bandPtr, OTFlags* flagPtr)
  2403.                         { return OTGetPriorityMessage(this, ctlbuf, databuf, bandPtr, flagPtr); }
  2404.             OSStatus    PutMessage(const struct strbuf* ctlbuf, const struct strbuf* databuf,
  2405.                                    OTFlags flags)
  2406.                         { return OTPutMessage(this, ctlbuf, databuf, flags); }
  2407.             OSStatus    PutPriorityMessage(const struct strbuf* ctlbuf, const struct strbuf* databuf,
  2408.                                            OTBand band, OTFlags flags)
  2409.                         { return OTPutPriorityMessage(this, ctlbuf, databuf, band, flags); }
  2410.                         
  2411.     };
  2412.         
  2413. /*    -------------------------------------------------------------------------
  2414.     Class TEndpoint
  2415.     
  2416.     This class is the interface to all TPI modules, which constitute the
  2417.     vast majority of protocols, with the exception of link-layer protocols.
  2418.     ------------------------------------------------------------------------- */
  2419.  
  2420.     class TEndpoint : public TProvider
  2421.     {
  2422.         public:
  2423.         //
  2424.         // Miscellaneous informative functions
  2425.         //
  2426.             OSStatus    GetEndpointInfo(TEndpointInfo* info)
  2427.                         { return OTGetEndpointInfo(this, info); }
  2428.                         
  2429.             OSStatus    GetProtAddress(TBind* boundAddr, TBind* peerAddr)
  2430.                         { return OTGetProtAddress(this, boundAddr, peerAddr); }
  2431.                         
  2432.             OSStatus    ResolveAddress(TBind* reqAddr, TBind* retAddr, OTTimeout timeout)
  2433.                         { return OTResolveAddress(this, reqAddr, retAddr, timeout); }
  2434.                         
  2435.             OTResult    GetEndpointState()        
  2436.                         { return OTGetEndpointState(this); }
  2437.                         
  2438.             OTResult    Look()
  2439.                         { return OTLook(this); }
  2440.                         
  2441.             OTResult    Sync()
  2442.                         { return OTSync(this); }
  2443.         //
  2444.         // Allocating structures
  2445.         //
  2446.             void*        Alloc(OTStructType structType, UInt32 fields, OSStatus* err = NULL)
  2447.                         { return OTAlloc(this, structType, fields, err); }
  2448.                         
  2449.             OTResult    Free(void* ptr, OTStructType structType)
  2450.                         { return OTFree(ptr, structType); }
  2451.         //
  2452.         // Option Management
  2453.         //
  2454.             OSStatus    OptionManagement(TOptMgmt* req, TOptMgmt* ret)
  2455.                         { return OTOptionManagement(this, req, ret); }
  2456.         //
  2457.         // Bind/Unbind
  2458.         //
  2459.             OSStatus    Bind(TBind* reqAddr, TBind* retAddr)
  2460.                         { return OTBind(this, reqAddr, retAddr); }
  2461.                         
  2462.             OSStatus    Unbind()
  2463.                         { return OTUnbind(this); }
  2464.         //
  2465.         // Connection creation and tear-down
  2466.         //
  2467.             OSStatus    Connect(TCall* sndCall, TCall* rcvCall)
  2468.                         { return OTConnect(this, sndCall, rcvCall); }
  2469.                         
  2470.             OSStatus    RcvConnect(TCall* call)
  2471.                         { return OTRcvConnect(this, call); }
  2472.                         
  2473.             OSStatus    Listen(TCall* call)
  2474.                         { return OTListen(this, call); }
  2475.                         
  2476.             OSStatus    Accept(EndpointRef resRef, TCall* call)
  2477.                         { return OTAccept(this, resRef, call); }
  2478.                         
  2479.             OSStatus    SndDisconnect(TCall* call)
  2480.                         { return OTSndDisconnect(this, call); }
  2481.                         
  2482.             OSStatus    SndOrderlyDisconnect()
  2483.                         { return OTSndOrderlyDisconnect(this); }
  2484.                         
  2485.             OSStatus    RcvDisconnect(TDiscon* discon)
  2486.                         { return OTRcvDisconnect(this, discon); }
  2487.                         
  2488.             OSStatus    RcvOrderlyDisconnect()
  2489.                         { return OTRcvOrderlyDisconnect(this); }
  2490.         //
  2491.         // Connection-oriented data transfer
  2492.         //
  2493.             OTResult    Snd(void* buf, size_t nbytes, OTFlags flags)
  2494.                         { return OTSnd(this, buf, nbytes, flags); }
  2495.                         
  2496.             OTResult    Rcv(void* buf, size_t nbytes, OTFlags* flagP)
  2497.                         { return OTRcv(this, buf, nbytes, flagP); }
  2498.         //
  2499.         // Non-connection-oriented data transfer
  2500.         //
  2501.             OSStatus    SndUData(TUnitData* udata)
  2502.                         { return OTSndUData(this, udata); }
  2503.                         
  2504.             OSStatus    RcvUData(TUnitData* udata, OTFlags* flagP)
  2505.                         { return OTRcvUData(this, udata, flagP); }
  2506.                         
  2507.             OSStatus    RcvUDErr(TUDErr* uderr)
  2508.                         { return OTRcvUDErr(this, uderr); }
  2509.         //
  2510.         // Connection-oriented transactions
  2511.         //
  2512.             OSStatus    SndRequest(TRequest* req, OTFlags reqFlags)
  2513.                         { return OTSndRequest(this, req, reqFlags); }
  2514.  
  2515.             OSStatus    RcvReply(TReply* reply, OTFlags* replyFlags)
  2516.                         { return OTRcvReply(this, reply, replyFlags); }
  2517.                         
  2518.             OSStatus    SndReply(TReply* reply, OTFlags flags)
  2519.                         { return OTSndReply(this, reply, flags); }
  2520.                         
  2521.             OSStatus    RcvRequest(TRequest* req, OTFlags* flags)
  2522.                         { return OTRcvRequest(this, req, flags); }
  2523.                         
  2524.             OSStatus    CancelRequest(OTSequence seq)
  2525.                         { return OTCancelRequest(this, seq); }
  2526.                         
  2527.             OSStatus    CancelReply(OTSequence seq)
  2528.                         { return OTCancelReply(this, seq); }
  2529.         //
  2530.         // Non-connection-oriented transactions
  2531.         //
  2532.             OSStatus    SndURequest(TUnitRequest* req, OTFlags reqFlags)
  2533.                         { return OTSndURequest(this, req, reqFlags); }
  2534.  
  2535.             OSStatus    RcvUReply(TUnitReply* reply, OTFlags* replyFlags)
  2536.                         { return OTRcvUReply(this, reply, replyFlags); }
  2537.                         
  2538.             OSStatus    SndUReply(TUnitReply* reply, OTFlags flags)
  2539.                         { return OTSndUReply(this, reply, flags); }
  2540.                         
  2541.             OSStatus    RcvURequest(TUnitRequest* req, OTFlags* flags)
  2542.                         { return OTRcvURequest(this, req, flags); }
  2543.                         
  2544.             OSStatus    CancelURequest(OTSequence seq)
  2545.                         { return OTCancelURequest(this, seq); }
  2546.                         
  2547.             OSStatus    CancelUReply(OTSequence seq)
  2548.                         { return OTCancelUReply(this, seq); }
  2549.         //
  2550.         // Miscellaneous functions
  2551.         //
  2552.             OTResult    CountDataBytes(size_t* countPtr)
  2553.                         { return OTCountDataBytes(this, countPtr); }
  2554.     };
  2555.  
  2556. /*    -------------------------------------------------------------------------
  2557.     CLASS TMapper
  2558.     
  2559.     This class is the interface to naming protocols.
  2560.     ------------------------------------------------------------------------- */
  2561.  
  2562.     class TMapper : public TProvider
  2563.     {
  2564.         public:
  2565.             OSStatus    RegisterName(TRegisterRequest* req, TRegisterReply* reply)
  2566.                         { return OTRegisterName(this, req, reply); }
  2567.                     
  2568.             OSStatus    DeleteName(TNetbuf* name)
  2569.                         { return OTDeleteName(this, name); }
  2570.                     
  2571.             OSStatus    DeleteName(OTNameID id)    
  2572.                         { return OTDeleteNameByID(this, id); }
  2573.                     
  2574.             OSStatus    LookupName(TLookupRequest* req, TLookupReply* reply)
  2575.                         { return OTLookupName(this, req, reply); }
  2576.     };
  2577.     
  2578. #endif    /* OTKERNEL    */
  2579. #endif    /* __cplusplus */
  2580.  
  2581. #if GENERATINGPOWERPC
  2582. #pragma options align=reset
  2583. #endif
  2584.  
  2585. #if GENERATING68K && defined(__MWERKS__)
  2586. #pragma pointers_in_A0
  2587. #endif
  2588.  
  2589. #endif    /* __OPENTRANSPORT__ */
  2590.  
  2591.